EN4_PRC8/_module/nss/rtrw_fleetrig.nss

39 lines
1.0 KiB
Plaintext
Raw Permalink Normal View History

#include "prc_inc_racial"
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)))
{
iFlag = 0;
iRace = MyPRCGetRacialType(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("RTRW_cguard1_S");
if (!GetIsObjectValid(oGuard))
oGuard = GetObjectByTag("RTRW_cguard2_S");
if (!GetIsEnemy(oGuard,oCreature))
iFlag = 1;
if (iFlag == 0)
{
sTag = "RTRW_FleeTo" + IntToString(Random(4)+1);
lLoc = GetLocation(GetObjectByTag(sTag));
DelayCommand(0.1f,AssignCommand(oCreature,ClearAllActions()));
DelayCommand(0.5f,AssignCommand(oCreature,ActionMoveToLocation(lLoc,TRUE)));
}
}
}