Files
dsrc/sku.0/sys.server/compiled/game/script/quest/util/quest_creature.script
T

74 lines
2.2 KiB
Plaintext

/**********************************************************************
* Copyright (c)2000-2002 Sony Online Entertainment Inc.
* All Rights Reserved
*
* Title: quest_creature
* Description: Script that attaches to any creature spawned via the quest
* spawner
* @author $Author:$
* @version $Revision:$
**********************************************************************/
/***** INCLUDES ********************************************************/
/***** CONSTANTS *******************************************************/
const string VAR_SPAWNER_CURRENT_POPULATION = "quest_spawner.current_pop";
const string VAR_SPAWNED_BY = "quest_spawner.spawned_by";
/***** TRIGGERS ********************************************************/
trigger OnIncapacitated(obj_id attacker)
{
LOG("quests", "quest_creature.OnIncapacitated(" + self + ", " + attacker + ") - notifying spawner");
notifySpawner();
return SCRIPT_CONTINUE;
}
trigger OnDestroy()
{
LOG("quests", "quest_creature.OnDestroy(" + self + ") - notifying spawner");
if(! isIncapacitated(self))
notifySpawner();
return SCRIPT_CONTINUE;
}
/***** MESSAGEHANDLERS *************************************************/
/***** COMMANDHANDLERS *************************************************/
/***** FUNCTIONS *******************************************************/
void notifySpawner()
{
obj_id self = getSelf();
obj_id spawner = getObjIdObjVar(self, VAR_SPAWNED_BY);
if (isIdValid(spawner))
{
if (spawner.isLoaded())
{
if (hasObjVar(spawner, VAR_SPAWNER_CURRENT_POPULATION))
{
// If the spawner isn't keeping track of current population, don't decrement the counter.
int population = getIntObjVar(spawner, VAR_SPAWNER_CURRENT_POPULATION);
setObjVar(spawner, VAR_SPAWNER_CURRENT_POPULATION, population - 1);
//LOG("LOG_CHANNEL", "population ->" + population);
}
else
{
LOG("quests", "quest_creature.notifySpawner(" + self + ") - spawner doesn't have objvar " + VAR_SPAWNER_CURRENT_POPULATION);
}
}
else
{
LOG("quests", "quest_creature.notifySpawner(" + self + ") - spawner " + spawner + " isn't loaded");
}
}
else
{
LOG("quests", "quest_creature.notifySpawner(" + self + ") - invalid spawner id");
}
}