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

123 lines
4.6 KiB
Plaintext

// MAGE ASSASSIN - Script
int fnDeadTest(object oTarget)
{ // returns TRUE is PC is dead or in Outer planes
int nRet=FALSE;
string sTag;
if (GetIsDead(oTarget)==TRUE) nRet=TRUE;
if (oTarget==OBJECT_INVALID) nRet=TRUE;
if (nRet==FALSE)
{ // test area
sTag=GetTag(GetArea(oTarget));
if (sTag=="ThePlaneofInBetween"||sTag=="TheRealmofShadows") nRet=TRUE;
} // test area
return nRet;
} // fnDeadTest()
void main()
{
object oMe=OBJECT_SELF;
int nSpeed=GetLocalInt(oMe,"nSpeed");
int nState=GetLocalInt(oMe,"nState");
int nTarget=GetLocalInt(oMe,"nTarget");
object oMod=GetModule();
string sTID;
object oTarget;
object oDest;
object oFinal;
object oPC;
int nN=1;
if (nTarget==1) sTID="UNC";
else if (nTarget==2) sTID="SPID";
else if (nTarget==3) sTID="UND";
else if (nTarget==4) sTID="DWF";
SetLocalString(oMe,"sTargetTeam",sTID);
oFinal=GetWaypointByTag("MAGEASS_SKULK"+IntToString(nTarget));
oTarget=GetLocalObject(oMod,"oTeamLead"+sTID);
if (GetIsInCombat(oMe)==FALSE)
{ // not in combat
if (oTarget!=OBJECT_INVALID||fnDeadTest(oTarget)!=TRUE)
{ // target still lives
switch(nState)
{ // Mage AI State
case 0: { // go to rally point
oDest=GetWaypointByTag("MAGEASS_RALLY");
if(GetCurrentAction()!=ACTION_MOVETOPOINT)
{ // move
ActionForceMoveToObject(oDest,TRUE,1.0,60.0);
ActionDoCommand(SetLocalInt(oMe,"nState",1));
} // move
break;
} // go to rally point
case 1: { // go to skulk point
if(GetCurrentAction()!=ACTION_MOVETOPOINT)
{ // move
ActionForceMoveToObject(oFinal,TRUE,1.0,120.0);
ActionDoCommand(SetLocalInt(oMe,"nState",2));
ActionDoCommand(SetLocalInt(oMe,"nSpeed",4));
} // move
break;
} // go to skulk point
case 2: { // skulk
if(GetArea(oTarget)==GetArea(oMe))
{ // same area
if(GetHasSpell(SPELL_SEE_INVISIBILITY)==TRUE)
{ // cast see invisibility
ActionCastSpellAtObject(SPELL_SEE_INVISIBILITY,oMe,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
} // cast see invisibility
if (GetHasSpell(SPELL_IMPROVED_INVISIBILITY)==TRUE)
{ // cast improved invisibility
ActionCastSpellAtObject(SPELL_IMPROVED_INVISIBILITY,oMe,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
} // cast improved invisibility
else if (GetHasSpell(SPELL_INVISIBILITY)==TRUE)
{ // cast invisibility
ActionCastSpellAtObject(SPELL_INVISIBILITY,oMe,METAMAGIC_ANY,FALSE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
} // cast invisibility
SetLocalInt(oMe,"nState",3);
} // same area
break;
} // skulk
case 3: { // setup hostile
SetIsTemporaryEnemy(oTarget,oMe);
nN=1;
oPC=GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_FRIEND,oMe,nN,CREATURE_TYPE_IS_ALIVE,TRUE);
while(oPC!=OBJECT_INVALID)
{ // adjust escorts
if (GetLocalInt(oPC,"nTarget")==nTarget) SetIsTemporaryEnemy(oTarget,oPC);
nN++;
oPC=GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_FRIEND,oMe,nN,CREATURE_TYPE_IS_ALIVE,TRUE);
} // adjust escorts
SetLocalInt(oMe,"nState",4);
break;
} // setup hostile
case 4: { // watch for enemies
nN=1;
oPC=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oMe,nN,CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN);
while(oPC!=OBJECT_INVALID)
{ // check
if (GetIsEnemy(oPC)==FALSE)
{ // check to see if should be enemy
if (GetIsFriend(oPC,oTarget)) SetIsTemporaryEnemy(oPC,oMe);
} // check to see if should be enemy
nN++;
oPC=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oMe,nN,CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN);
} // check
nSpeed=10;
break;
} // watch for enemies
default: break;
} // Mage AI State
DelayCommand(IntToFloat(nSpeed),ExecuteScript("mage_assassin",oMe));
} // target still lives
else
{ // my job is done
AssignCommand(oMe,SpeakString("My job is done."));
DelayCommand(10.0,SendMessageToPC(oTarget,"You had a contract placed on your head with the mages' guild. That contract has been met."));
DelayCommand(5.0,DestroyObject(oMe));
} // my job is done
} // not in combat
else
{
DelayCommand(3.0,ExecuteScript("mage_assassin",oMe));
}
}