159 lines
6.1 KiB
Plaintext
159 lines
6.1 KiB
Plaintext
////////////////////////////////////////////////////////
|
|
// HARVEST command
|
|
//======================================================
|
|
// By Deva Bryson Winblood 12/01/2003
|
|
////////////////////////////////////////////////////////
|
|
#include "rts_pathing"
|
|
#include "rts_header"
|
|
#include "antistuck_h"
|
|
|
|
void main()
|
|
{
|
|
object oMe=OBJECT_SELF;
|
|
int nState=GetLocalInt(oMe,"nSState");
|
|
location lLoc=GetLocalLocation(oMe,"lLocation");
|
|
int nC=0;
|
|
object oMod=GetModule();
|
|
int nR;
|
|
int nHas=FALSE;
|
|
float fDist=GetDistanceBetweenLocations(GetLocation(oMe),lLoc);
|
|
int nErr;
|
|
int nRun=GetLocalInt(oMe,"nRun");
|
|
effect eVFX=EffectVisualEffect(VFX_FNF_IMPLOSION);
|
|
string sID=GetLocalString(OBJECT_SELF,"sTeamID");
|
|
object oBase=GetWaypointByTag(sID+"_START");
|
|
object oVault=GetObjectByTag(sID+"_VAULT");
|
|
object oPool;
|
|
object oMove;
|
|
object oHarvest;
|
|
object oH;
|
|
int nMethod=0;
|
|
object oLeader=GetLocalObject(oMod,"oTeamLead"+sID);
|
|
if (GetItemPossessedBy(OBJECT_SELF,"MANA_CRYSTAL_1")!=OBJECT_INVALID) nHas=TRUE;
|
|
if (GetItemPossessedBy(OBJECT_SELF,"MANA_CRYSTAL_2")!=OBJECT_INVALID) nHas=TRUE;
|
|
if (GetItemPossessedBy(OBJECT_SELF,"MANA_CRYSTAL_5")!=OBJECT_INVALID) nHas=TRUE;
|
|
if (nHas==TRUE&&nState!=2&&nState!=3) { SetLocalInt(oMe,"nSState",2); nState=2; }
|
|
if (nHas==TRUE&&GetAreaFromLocation(lLoc)!=OBJECT_INVALID) DeleteLocalLocation(oMe,"lLocation");
|
|
switch(nState)
|
|
{ // main state
|
|
case 0: { // check
|
|
SetAILevel(oMe,AI_LEVEL_NORMAL);
|
|
if (nHas==TRUE) SetLocalInt(oMe,"nSState",2);
|
|
else { SetLocalInt(oMe,"nSState",1); }
|
|
break;
|
|
} // check
|
|
case 1: { // move to harvest point
|
|
if (fDist<1.5&&GetArea(oMe)==GetAreaFromLocation(lLoc))
|
|
SetLocalInt(oMe,"nSState",5);
|
|
else
|
|
{ // move
|
|
if (GetArea(oMe)==GetAreaFromLocation(lLoc))
|
|
{ // same area pathing
|
|
if (GetDistanceBetweenLocations(GetLocation(oMe),lLoc)>1.5)
|
|
{ // not close enough
|
|
if (GetCurrentAction(oMe)!=ACTION_MOVETOPOINT)
|
|
{ // move
|
|
AssignCommand(oMe,ClearAllActions(TRUE));
|
|
AssignCommand(oMe,ActionMoveToLocation(lLoc,TRUE));
|
|
} // move
|
|
} // not close enough
|
|
else
|
|
{ // arrived
|
|
AssignCommand(oMe,ClearAllActions(TRUE));
|
|
SetLocalInt(oMe,"nSState",5);
|
|
} // arrived
|
|
} // same area pathing
|
|
else
|
|
{ // long distance pathing
|
|
if (GetCurrentAction(oMe)!=ACTION_MOVETOPOINT)
|
|
{ // not moving
|
|
AssignCommand(oMe,ClearAllActions(TRUE));
|
|
AssignCommand(oMe,ActionForceMoveToLocation(lLoc,TRUE,240.0));
|
|
} // not moving
|
|
} // long distance pathing
|
|
} // move
|
|
break;
|
|
} // move to harvest point
|
|
case 2: { // return to lair with mana
|
|
nErr=0;
|
|
if (GetArea(oMe)!=GetArea(oVault))
|
|
{
|
|
if (sID=="SPID") nErr=3;
|
|
else if (sID=="DWF") nErr=2;
|
|
else if (sID=="UNC") nErr=1;
|
|
else if (sID=="UND") nErr=3;
|
|
if (GetIsDay()==TRUE&&GetLocalInt(oMod,GetResRef(oMe)+"_light")==2) nErr=4; // light fatal
|
|
oMove=fnPathNextDestination(GetArea(oMe),sID,nErr);
|
|
if (oMove!=OBJECT_INVALID)
|
|
AssignCommand(oMe,ASActionMoveToObject(oMove,nRun,8.0));
|
|
}
|
|
else
|
|
{ // deposit mana
|
|
SetLocalInt(oMe,"nSState",3);
|
|
} // deposit mana
|
|
break;
|
|
} // return to lair with mana
|
|
case 3: { // deposit mana
|
|
fDist=GetDistanceBetween(oMe,oVault);
|
|
if ((fDist==0.0&&GetArea(oVault)!=GetArea(OBJECT_SELF))||fDist>1.5)
|
|
{ // move
|
|
nErr=fnMoveToDestination(oVault,TRUE);
|
|
if (nHas==FALSE)
|
|
{ // delivered
|
|
SetLocalInt(oMe,"nSState",6);
|
|
} // delivered
|
|
} // move
|
|
else if (nHas==TRUE)
|
|
{ // move away and try again
|
|
AssignCommand(oMe,ClearAllActions());
|
|
AssignCommand(oMe,ActionMoveAwayFromObject(oVault,TRUE,8.0));
|
|
} // move away and try again
|
|
break;
|
|
} // deposit mana
|
|
case 5: { // harvest
|
|
oPool=GetNearestObjectByTag("StrongManaPool");
|
|
fDist=GetDistanceBetween(oPool,OBJECT_SELF);
|
|
if((fDist==0.0&&GetArea(oPool)!=GetArea(OBJECT_SELF))||fDist>10.0)
|
|
{ // try a mana pool
|
|
oPool=GetNearestObjectByTag("ManaPool");
|
|
fDist=GetDistanceBetween(oPool,OBJECT_SELF);
|
|
if((fDist==0.0&&GetArea(oPool)!=GetArea(OBJECT_SELF))||fDist>10.0)
|
|
{ // try a minor mana pool
|
|
oPool=GetNearestObjectByTag("MinorManaPool");
|
|
fDist=GetDistanceBetween(oPool,OBJECT_SELF);
|
|
if ((fDist==0.0&&GetArea(oPool)!=GetArea(OBJECT_SELF))||fDist>10.0)
|
|
{ // could not find
|
|
oPool=GetLocalObject(OBJECT_SELF,"oDestWP");
|
|
SetLocalObject(OBJECT_SELF,"oDestWP",OBJECT_INVALID);
|
|
SetLocalInt(OBJECT_SELF,"nSState",7);
|
|
if (GetAbilityScore(OBJECT_SELF,ABILITY_INTELLIGENCE)>9) ActionSpeakString("I could not find a mana pool within 10 meters of the specified harvest location!");
|
|
} // could not find
|
|
} // try a minor mana pool
|
|
} // try a mana pool
|
|
if ((fDist!=0.0&&fDist<10.1)||(fDist==0.0&&GetArea(oPool)==GetArea(OBJECT_SELF)))
|
|
{ // it is in range
|
|
AssignCommand(OBJECT_SELF,ClearAllActions());
|
|
AssignCommand(OBJECT_SELF,ASActionMoveToObject(oPool));
|
|
AssignCommand(OBJECT_SELF,ActionInteractObject(oPool));
|
|
}
|
|
break;
|
|
} // harvest
|
|
case 6: { // job complete
|
|
SetAILevel(oMe,AI_LEVEL_DEFAULT);
|
|
AssignCommand(oMe,ClearAllActions());
|
|
AssignCommand(oMe,ASActionMoveToObject(oVault,nRun,4.0));
|
|
AssignCommand(oMe,ActionMoveAwayFromObject(oVault,nRun,7.0));
|
|
SetLocalInt(oMe,"nMState",0);
|
|
SetLocalInt(oMe,"nSState",0);
|
|
break;
|
|
} // job complete
|
|
case 7: { // cannot complete job
|
|
SetAILevel(oMe,AI_LEVEL_DEFAULT);
|
|
AssignCommand(oMe,ClearAllActions());
|
|
SetLocalInt(oMe,"nMState",11); // Guard the lair
|
|
SetLocalInt(oMe,"nSState",0);
|
|
break;
|
|
} // cannot complete job
|
|
} // main state
|
|
}
|