Files
dsrc/sku.0/sys.server/compiled/game/script/systems/spawning/spawned_tracker.script
T

73 lines
2.1 KiB
Plaintext

include library.utils;
trigger OnIncapacitated(obj_id objAttacker)
{
if(!utils.hasScriptVar(self, "intCleanedUp"))
{
utils.setScriptVar(self, "intCleanedUp", 1);
obj_id objParent = getObjIdObjVar(self, "objParent");
float fltRespawnTime = getFloatObjVar(self, "fltRespawnTime");
//If a mob or object has a deathtracker on it it's to track which location they were spawned at for a random spawner
//so that we can open that spot up for spawning again.
if (utils.hasScriptVar(self, "deathTracker"))
{
location loc = utils.getLocationScriptVar(self, "deathTracker");
dictionary params = new dictionary ();
params.put ("loc", loc );
messageTo ( objParent, "spawnDestroyed", params, fltRespawnTime, false );
return SCRIPT_CONTINUE;
}
messageTo(objParent, "spawnDestroyed", null, fltRespawnTime, false);
}
return SCRIPT_CONTINUE;
}
trigger OnDestroy()
{
//If we for some reason don't want to count the deaths of a spawned object and not have it call the respawn, attach this obj var to it.
if (hasObjVar(self, "dontCountDeath"))
return SCRIPT_CONTINUE;
if(!utils.hasScriptVar(self, "intCleanedUp"))
{
utils.setScriptVar(self, "intCleanedUp", 1);
obj_id objParent = getObjIdObjVar(self, "objParent");
if (!isIdValid(objParent)) //do not check exists(objParent) as this will break when spawning
return SCRIPT_CONTINUE;
float fltRespawnTime = getFloatObjVar(self, "fltRespawnTime");
if (utils.hasScriptVar(self, "deathTracker"))
{
location loc = utils.getLocationScriptVar(self, "deathTracker");
dictionary params = new dictionary ();
params.put ("loc", loc );
messageTo ( objParent, "spawnDestroyed", params, fltRespawnTime, false );
return SCRIPT_CONTINUE;
}
messageTo(objParent, "spawnDestroyed", null, fltRespawnTime, false);
}
return SCRIPT_CONTINUE;
}
messageHandler selfDestruct()
{
if(hasObjVar(self, "force_cleanup"))
{
//kill NPC so it can be properly cleaned up
setPosture(self, POSTURE_INCAPACITATED);
}
destroyObject(self);
return SCRIPT_CONTINUE;
}
trigger OnRemovingFromWorld()
{
return SCRIPT_CONTINUE;
}