HoS_PRC8/_mod/_module/nss/wazoo_mordspawn.nss
Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

69 lines
2.7 KiB
Plaintext

// wazoo_mordspawn - Mordenkainen's Faithful Hound Spawn
void fnMordenkainenEffects(object oMe)
{ // PURPOSE: Handle true seeing, invis, and barking when detecting new enemies
effect eE;
object oOb;
object oAttack;
int nN;
float fDelay=5.0+(IntToFloat(Random(15))/10.0);
eE=EffectInvisibility(INVISIBILITY_TYPE_IMPROVED);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eE,oMe,8.0);
eE=EffectTrueSeeing();
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eE,oMe,8.0);
if (!GetIsInCombat(oMe))
{ // not in combat
if (GetDistanceBetween(oMe,GetMaster(oMe))>8.0&&GetArea(oMe)==GetArea(GetMaster(oMe)))
{ // move back
AssignCommand(oMe,ClearAllActions(TRUE));
AssignCommand(oMe,ActionMoveToObject(GetMaster(oMe),TRUE,3.0));
} // move back
else if (GetArea(oMe)!=GetArea(GetMaster(oMe)))
{ // jump
AssignCommand(oMe,ClearAllActions(TRUE));
AssignCommand(oMe,JumpToObject(GetMaster(oMe)));
} // jump
nN=1;
oOb=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oMe,nN,CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY);
while(oOb!=OBJECT_INVALID)
{ // new object
if (GetLocalInt(oOb,"bWZMordDetect")==FALSE&&GetLocalInt(oMe,"bWZBarkedRecent")==FALSE)
{ // detect new creature
SetLocalInt(oOb,"bWZMordDetect",TRUE);
DelayCommand(30.0,DeleteLocalInt(oOb,"bWZMordDetect"));
SetLocalInt(oMe,"bWZBarkedRecent",TRUE);
DelayCommand(8.0,DeleteLocalInt(oOb,"bWZBarkedRecent"));
AssignCommand(oMe,ClearAllActions(TRUE));
PlaySound("as_an_dogbark2");
if (GetDistanceBetween(oMe,oOb)<5.0) oAttack=oOb;
} // detect new creature
nN++;
oOb=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oMe,nN,CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY);
} // new object
if (GetIsObjectValid(oAttack))
{ // attack
AssignCommand(oMe,ActionAttack(oAttack));
} // attack
} // not in combat
else
{ // in combat
if (GetDistanceBetween(oMe,GetMaster(oMe))>10.0&&GetArea(oMe)==GetArea(GetMaster(oMe)))
{ // move back
AssignCommand(oMe,ClearAllActions(TRUE));
AssignCommand(oMe,ActionMoveToObject(GetMaster(oMe),TRUE,3.0));
} // move back
else if (GetArea(oMe)!=GetArea(GetMaster(oMe)))
{ // jump
AssignCommand(oMe,ClearAllActions(TRUE));
AssignCommand(oMe,JumpToObject(GetMaster(oMe)));
} // jump
} // in combat
DelayCommand(fDelay,fnMordenkainenEffects(oMe));
} // fnMordenkainenEffects()
void main()
{
fnMordenkainenEffects(OBJECT_SELF);
}