void main() { object oCreature; object oGuard; location lLoc; string sTag; int iRace; int iFlag; oCreature = GetEnteringObject(); //Use GetIsEnemy to tell them to flee if (!GetIsPC(oCreature) && !GetIsPC(GetMaster(oCreature)) && GetLocalInt(oCreature,"Flee") == 0) { SetLocalInt(oCreature,"Flee",1); iFlag = 0; iRace = GetRacialType(oCreature); if (iRace == RACIAL_TYPE_ANIMAL || iRace == RACIAL_TYPE_BEAST || iRace == RACIAL_TYPE_UNDEAD || iRace == RACIAL_TYPE_VERMIN || iRace == RACIAL_TYPE_OOZE || iRace ==RACIAL_TYPE_CONSTRUCT) iFlag = 1; oGuard = GetObjectByTag("SM1_cguard1_S"); if (!GetIsObjectValid(oGuard)) oGuard = GetObjectByTag("SM1_cguard2_S"); if (!GetIsEnemy(oGuard,oCreature)) iFlag = 1; if (iFlag == 0) { sTag = "SM1_FleeTo" + IntToString(Random(3)+1); lLoc = GetLocation(GetObjectByTag(sTag)); DelayCommand(0.1f,AssignCommand(oCreature,ClearAllActions())); DelayCommand(0.3f,AssignCommand(oCreature,ActionMoveToLocation(lLoc,TRUE))); } } }