47 lines
1.7 KiB
Plaintext
47 lines
1.7 KiB
Plaintext
// MEL_HB - Mana Elemental Heartbeat
|
|
#include "antistuck_h"
|
|
|
|
void main()
|
|
{ // purpose handle the mana elemental
|
|
object oMe=OBJECT_SELF;
|
|
object oHome=GetLocalObject(oMe,"oManaPool");
|
|
object oEnemy=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oMe,1,CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY);
|
|
if (oEnemy==OBJECT_INVALID&&GetIsInCombat(oMe)==FALSE)
|
|
{ // okay to move
|
|
if (oHome!=OBJECT_INVALID)
|
|
{ // pool exists
|
|
if (GetArea(oMe)!=GetArea(oHome))
|
|
{ // teleport
|
|
AssignCommand(oMe,ClearAllActions());
|
|
AssignCommand(oMe,JumpToObject(oHome));
|
|
} // teleport
|
|
else if (GetDistanceBetween(oMe,oHome)>8.0)
|
|
{ // move back to mana pool
|
|
AssignCommand(oMe,ASActionMoveToObject(oHome,TRUE,3.0));
|
|
} // move back to mana pool
|
|
else
|
|
{ // wander
|
|
oHome=GetNearestObject(OBJECT_TYPE_WAYPOINT,oMe,d10());
|
|
if (oHome==OBJECT_INVALID) oHome=GetNearestObject(OBJECT_TYPE_WAYPOINT,oMe,d10());
|
|
if (oHome!=OBJECT_INVALID)
|
|
{ // move
|
|
AssignCommand(oMe,ASActionMoveToObject(oHome,FALSE,1.0));
|
|
} // move
|
|
} // wander
|
|
} // pool exists
|
|
else
|
|
{ // pool does not exist
|
|
oHome=GetNearestObject(OBJECT_TYPE_WAYPOINT,oMe,d10());
|
|
if (oHome==OBJECT_INVALID) oHome=GetNearestObject(OBJECT_TYPE_WAYPOINT,oMe,d10());
|
|
if (oHome!=OBJECT_INVALID&&GetCurrentAction(oMe)!=ACTION_MOVETOPOINT)
|
|
{ // move
|
|
AssignCommand(oMe,ASActionMoveToObject(oHome,FALSE,1.0));
|
|
} // move
|
|
} // pool does not exist
|
|
} // okay to move
|
|
else
|
|
{ // combat
|
|
ExecuteScript("nw_c2_default1",oMe);
|
|
} // combat
|
|
} // purpose handle the mana elemental
|