//:://///////////////////////////////////////////// //:: swt_NPC_random //:: swt_NPC_random.nss //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /* */ //::////////////////////////////////////////////// //:: Created By: Lysandius //:: Created On: 09-07-2002 //::////////////////////////////////////////////// void swtSit(); void swtWalk(); void swtChange(); void main() { if((d20() == 1)&&(GetLocalInt(OBJECT_SELF, "nSitting"))) { ClearAllActions(); swtChange(); } else if((d6() == 1)&&(!GetLocalInt(OBJECT_SELF, "nSitting"))) { ClearAllActions(); swtChange(); } } void swtSit() { object oSittable = GetNearestObjectByTag("Sittable"); SetLocalObject(OBJECT_SELF,"oMychair",oSittable); ActionMoveToLocation(GetLocation(oSittable)); // a1 No: go to the nearest sittable. //if(!GetIsObjectValid(GetSittingCreature(oSittable))) // q2 Is something sitting on the nearest sittable now? //{ SetLocalInt(OBJECT_SELF, "nSitting", 1); ActionSit(oSittable); // a2 No: sit down. //} //else //ActionRandomWalk(); // a2 Yes: start walking again. //} //else //ActionRandomWalk(); // a1 Yes: continue walking. } void swtWalk() { SetLocalInt(OBJECT_SELF, "nSitting", 0); ActionRandomWalk(); } void swtChange() { if(GetLocalInt(OBJECT_SELF, "nSitting")) swtWalk(); else swtSit(); }