Battledale_PRC8/_module/nss/jw_clone_ai.nss

89 lines
2.0 KiB
Plaintext
Raw Permalink Normal View History

/*
/////Usage: This is the combat scheduler script that also handles death for the clone. If you change the name make sure you change it in the Execute script both in this script and in the trigger script. Otherwise it should be named clone_hb
*/
#include "NW_I0_GENERIC"
#include "jw_privates_inc"
void main()
{
// Check if the copy is dead yet
if(GetIsDead(OBJECT_SELF))
{
object oItem;
int nSlot;
//Copy is dead so clean it out. and run the death script.
AssignCommand(OBJECT_SELF, SetIsDestroyable(TRUE));
for(nSlot=0; nSlot<=17; nSlot++)
{
oItem=GetItemInSlot(nSlot, OBJECT_SELF);
if (GetIsObjectValid(oItem))
{
SetPlotFlag(oItem,FALSE);
DestroyObject(oItem);
}
}
// Get rid of items in inventory
oItem=GetFirstItemInInventory(OBJECT_SELF);
object oStrip;
while (GetIsObjectValid(oItem))
{
oStrip=oItem;
SetPlotFlag(oStrip,FALSE);
DestroyObject(oStrip);
oItem=GetNextItemInInventory(OBJECT_SELF);
}
ExecuteScript("nw_c2_default7", OBJECT_SELF);
DestroyObject(OBJECT_SELF, 0.1);
}
else
{
object oEnemy=GetNearestSeenOrHeardEnemy();
object oTarget=GetTarget();
if ((GetIsDead(oTarget))||(GetArea(oTarget)!=GetArea(OBJECT_SELF))||(!GetIsEnemy(oTarget)))
{
SetTarget(OBJECT_INVALID);
oTarget=OBJECT_INVALID;
}
if (!GetIsObjectValid(oTarget))
{
oTarget=oEnemy;
if (GetIsObjectValid(oTarget))
{
SetTarget(oTarget);
}
}
if (GetIsObjectValid(oEnemy)&&(GetObjectSeen(oEnemy)))
{
if (!GetIsFighting(OBJECT_SELF))
{
DetermineCombatRound();
}
}
else if (GetIsObjectValid(oTarget))
{
ActionMoveToObject(oTarget);
}
// combat rounds are 6 seconds long
DelayCommand(6.0, ExecuteScript("jw_clone_ai", OBJECT_SELF));
}
}