100 lines
3.9 KiB
Plaintext
100 lines
3.9 KiB
Plaintext
///////////////////////////////////////////////////////////////////////////////
|
|
// rts_it_mag44 - The Maze Master's Horn
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
#include "rtsh_multiplay"
|
|
|
|
void fnEscapeMaze(object oT)
|
|
{ // bring NPC back out of maze
|
|
object oReturn;
|
|
if (GetTag(GetArea(oT))=="Maze"&&oT!=OBJECT_INVALID)
|
|
{ // bring back
|
|
oReturn=GetLocalObject(oT,"oMazeReturn");
|
|
AssignCommand(oT,ClearAllActions(TRUE));
|
|
AssignCommand(oT,JumpToObject(oReturn));
|
|
DelayCommand(10.0,AssignCommand(oT,DestroyObject(oReturn)));
|
|
} // bring back
|
|
} // fnEscapeMaze()
|
|
|
|
void IsTAlive(object oT)
|
|
{ // make sure target exists
|
|
if (GetIsDead(oT)!=TRUE&&oT!=OBJECT_INVALID) DelayCommand(10.0,IsTAlive(oT));
|
|
else { DestroyObject(oT); }
|
|
} // IsTAlive()
|
|
|
|
void fnMakeSureFollowersDontFollow(object oT)
|
|
{ // make sure followers within 30 meters do not follow
|
|
int nC=1;
|
|
object oCr=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oT,nC,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_FRIEND);
|
|
float fDist=GetDistanceBetween(oT,oCr);
|
|
int nS;
|
|
object oF;
|
|
object oMod=GetModule();
|
|
string sID;
|
|
while(oCr!=OBJECT_INVALID&&fDist<30.1)
|
|
{ // test
|
|
nS=GetLocalInt(oCr,"nMState");
|
|
if (nS==5||nS==4||nS==14)
|
|
{ // check to see if following target
|
|
oF=GetLocalObject(oCr,"oDestWP");
|
|
if (oF==oT)
|
|
{ // make return to base
|
|
SetLocalInt(oCr,"nMState",2);
|
|
SetLocalInt(oCr,"nSState",0);
|
|
sID=GetLocalString(oCr,"sTeamID");
|
|
oF=GetLocalObject(oMod,"oGUARD5"+sID);
|
|
SetLocalObject(oCr,"oDestWP",oF);
|
|
} // make return to base
|
|
} // check to see if following target
|
|
nC++;
|
|
oCr=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oT,nC,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_FRIEND);
|
|
fDist=GetDistanceBetween(oT,oCr);
|
|
} // test
|
|
} // fnMakeSureFollowersDontFollow()
|
|
|
|
void main()
|
|
{
|
|
object oPC=GetItemActivator();
|
|
object oTarget=GetItemActivatedTarget();
|
|
int bValid=TRUE;
|
|
object oWP=GetWaypointByTag("MAZE_SPAWN"+IntToString(d4()));
|
|
int nMana=fnGetTeamMana(oPC);
|
|
object oRet;
|
|
AssignCommand(oPC,ClearAllActions(TRUE));
|
|
AssignCommand(oPC,PlaySound("as_cv_ta-da1"));
|
|
if (GetIsPC(oTarget)==FALSE)
|
|
{ // make sure valid NPC
|
|
if (GetPlotFlag(oTarget)==TRUE) bValid=FALSE;
|
|
if (GetLocalString(oTarget,"sTeamID")==GetLocalString(oPC,"sTeamID")) bValid=FALSE;
|
|
} // make sure valid NPC
|
|
if (oTarget==oPC) bValid=FALSE; // can't send yourself
|
|
else if (GetPlotFlag(oTarget)==TRUE) bValid=FALSE; // can't send plot characters
|
|
else if (GetLocalInt(oTarget,"nMazeImmune")==1) bValid=FALSE; // way to disable the horn for some creatures
|
|
if (bValid==TRUE)
|
|
{ // okay target
|
|
if (nMana>49)
|
|
{ // has 50 mana
|
|
nMana=nMana-50;
|
|
if (GetIsPC(oTarget)==TRUE) SendMessageToPC(oTarget,GetName(oPC)+" has sent you into the maze.");
|
|
fnSetTeamMana(oPC,nMana);
|
|
SendMessageToPC(oPC,"You have sent "+GetName(oTarget)+" to the maze.");
|
|
oRet=CreateObject(OBJECT_TYPE_PLACEABLE,"rts_marker",GetLocation(oTarget));
|
|
AssignCommand(oRet,IsTAlive(oTarget));
|
|
SetLocalObject(oTarget,"oMazeReturn",oRet);
|
|
fnMakeSureFollowersDontFollow(oTarget);
|
|
AssignCommand(oTarget,ClearAllActions(TRUE));
|
|
AssignCommand(oTarget,JumpToObject(oWP));
|
|
if (GetIsPC(oTarget)!=TRUE) DelayCommand(HoursToSeconds(d6()),fnEscapeMaze(oTarget));
|
|
} // has 50 mana
|
|
else if (GetPlotFlag(oTarget)==TRUE)
|
|
{ SendMessageToPC(oPC,"You may not send plot characters to the maze."); }
|
|
else if (GetLocalInt(oTarget,"nMazeImmune")==1)
|
|
{ SendMessageToPC(oPC,"That target has some type of magic resistance that prevents you from sending them to the maze."); }
|
|
else
|
|
{ SendMessageToPC(oPC,"You do not have the 50 mana required to send someone to the maze."); }
|
|
} // okay target
|
|
else
|
|
{
|
|
SendMessageToPC(oPC,"That was not a valid target for the maze effect.");
|
|
}
|
|
}
|