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

220 lines
4.3 KiB
Plaintext

/**
* Copyright (c)2000-2002 Sony Online Entertainment Inc.
* All Rights Reserved
*
* Title: spawn_template.script
* Description: This script lives on all spawned templates. It notifies the master spawn object when they are destroyed.
* @author $Author:$
* @version $Revision:$
*/
inherits systems.spawning.spawn_base;
trigger OnAddedToWorld()
{
/*
//LOG("spawn_template", "Adding self to world");
if((hasObjVar(self, "intUnloaded"))||(hasObjVar(self, "intPersistent")))
{
//LOG("spawn_template", "Reregistering with master spawner");
removeObjVar(self, "intUnloaded");
dictionary dctParams = new dictionary();
string strRegionName = getStringObjVar(self, "strRegionName");
string strPlanet = getStringObjVar(self, "strPlanet");
int intObjVarId = getIntObjVar(self, "intObjVarId");
obj_id objMasterSpawner = getObjIdObjVar(self, "objMasterSpawner");
string strTemplate = getTemplateName(self);
string strLairType = "";
string strBuildingType = "";
if(hasObjVar(self, "spawning.lairType"))
{
strLairType = getStringObjVar(self, "spawning.lairType");
if(strLairType!="")
{
strTemplate = strTemplate +"."+strLairType;
}
}
if(hasObjVar(self, "spawning.buildingTrackingType"))
{
strBuildingType = getStringObjVar(self, "spawning.buildingTrackingType");
if(strBuildingType!="")
{
strTemplate = strTemplate +"."+strBuildingType;
}
}
dctParams.put("strTemplate", strTemplate);
dctParams.put("intObjVarId", intObjVarId);
dctParams.put("objSender", self);
dctParams.put("strLairType", strLairType);
dctParams.put("strBuildingType", strBuildingType);
dctParams.put("strRegionName", strRegionName);
dctParams.put("strPlanet", strPlanet);
debugServerConsoleMsg(self, "Sending Reload Request Message");
messageTo(objMasterSpawner, "template_Reload", dctParams, 0, true);
}
else
{
//LOG("spawn_template", "destroying self on //LOGin");
destroyObject(self);
}
*/
return SCRIPT_CONTINUE;
}
messageHandler template_Cleanup()
{
setObjVar(self, "intCleaningUp", 1);
destroyObject(self);
return SCRIPT_CONTINUE;
}
trigger OnRemovingFromWorld()
{
if(!hasObjVar(self, "intPersistent"))
{
destroyObject(self);
}
else
{
setObjVar(self, "intUnloaded", 1);
}
return SCRIPT_CONTINUE;
}
/**
@brief This trigger handles notification of the master spawner when the template is destroyed. This will be used to cleanup all necessary spawn information and counters
*/
trigger OnDestroy()
{
obj_id objMasterSpawner;
dictionary dctParams = new dictionary();
string strTemplate;
string strLairType;
string strBuildingType;
strTemplate = getTemplateName(self);
if(hasObjVar(self, "spawning.lairType"))
{
strLairType = getStringObjVar(self, "spawning.lairType");
if(strLairType!="")
{
strTemplate = strTemplate +"."+strLairType;
}
}
if(hasObjVar(self, "spawning.buildingTrackingType"))
{
strBuildingType = getStringObjVar(self, "spawning.buildingTrackingType");
if(strBuildingType!="")
{
strTemplate = strTemplate +"."+strBuildingType;
}
}
string strRegionName = getStringObjVar(self, "strRegionName");
string strPlanet = getStringObjVar(self, "strPlanet");
debugServerConsoleMsg(self, "Template being cleaned up is "+strTemplate);
objMasterSpawner = getObjIdObjVar(self, "objMasterSpawner");
//dctParams.put("objMasterSpawner", objMasterSpawner);
if (strTemplate != null)
dctParams.put("strTemplate", strTemplate);
if (strRegionName != null)
dctParams.put("strRegionName", strRegionName);
if (strPlanet != null)
dctParams.put("strPlanet", strPlanet);
debugServerConsoleMsg(self, "Sending Message");
// now fire it off to the master object
messageTo(objMasterSpawner, "template_Destroyed", dctParams, 0, false);
debugServerConsoleMsg(self, "Message Sent");
return SCRIPT_CONTINUE;
}
boolean checkIfInCombat(obj_id objLair)
{
int intNumberOfMobiles = getIntObjVar(objLair, "npc_lair.numberOfMobiles");
//debugSpeakMsg(objLair, "number of mobiles is "+intNumberOfMobiles);
for(int intI =0; intI<intNumberOfMobiles; intI++)
{
obj_id objCreature = getObjIdObjVar(objLair, "npc_lair.mobile."+intNumberOfMobiles);
int intState = getState(objCreature, STATE_COMBAT);
//debugSpeakMsg(objLair, "intState for "+objCreature+" is "+intState);
if(intState>0)
{
return true;
}
}
return false;
}