Planeshift
SpawnManager Class Reference

This class is periodically called by the engine to ensure that monsters (and other NPCs) are respawned appropriately. More...

#include <spawnmanager.h>

Public Member Functions

LootRandomizerGetLootRandomizer ()
 Returns the loot randomizer. More...
 
void KillNPC (gemActor *npc, gemActor *killer)
 Sets the NPC as dead, plays the death animation and triggers the loot generator. More...
 
void LoadHuntLocations (psSectorInfo *sectorinfo=0)
 Load hunt location. More...
 
void LoadSpawnRanges (SpawnRule *rule)
 Load all ranges for a rule. More...
 
void PreloadDatabase ()
 Load all rules into memory for future use. More...
 
void PreloadLootRules ()
 Load all loot categories into the manager for use in spawn rules. More...
 
void RemoveNPC (gemObject *obj)
 Kills the specified NPC, updates the database that he is "dead" and queues him for respawn according to the spawn rules. More...
 
void RepopulateItems (psSectorInfo *sectorinfo=0)
 Adds all items to the world. More...
 
void RepopulateLive (psSectorInfo *sectorinfo=0)
 Called at server startup to create all creatures currently marked as "living" in the database. More...
 
void Respawn (PID playerID, SpawnRule *spawnRule)
 Respawn a NPC given by playerID and find the position from the spawnRule. More...
 
void Respawn (psCharacter *chardata, InstanceID instance, csVector3 &where, float rot, const char *sector)
 Respawn a NPC in the given position. More...
 
void SpawnHuntLocations (Result &result, psSectorInfo *sectorinfo)
 Used by LoadHuntLocations() to spawn the hunt locations in game. More...
 
 SpawnManager (psDatabase *db, CacheManager *cachemanager, EntityManager *entitymanager, GEMSupervisor *gemsupervisor)
 
virtual ~SpawnManager ()
 
- Public Member Functions inherited from MessageManager< SpawnManager >
void HandleMessage (MsgEntry *msg, Client *client)
 Transfers the message to the manager specific function. More...
 
void Subscribe (FunctionPointer fpt, msgtype type, uint32_t flags=0x01)
 Subscribes this manager to a specific message type with a custom callback. More...
 
bool Unsubscribe (msgtype type)
 Unsubscribes this manager from a specific message type. More...
 
bool Unsubscribe (FunctionPointer handler, msgtype type)
 Unsubscribes a specific handler from a specific message type. More...
 
bool UnsubscribeAll ()
 Unsubscribes this manager from all message types. More...
 
virtual ~MessageManager ()
 Unsubscribes all messages then destroys this object. More...
 
- Public Member Functions inherited from MessageManagerBase
csArray< csString > DecodeCommandArea (Client *client, csString target)
 Decodes an area: expression. More...
 
gemObjectFindObjectByString (const csString &str, gemActor *me) const
 Find the object we are referring to in str. More...
 
ClientFindPlayerClient (const char *name)
 Finds Client* of character with given name. More...
 
virtual bool Verify (MsgEntry *pMsg, unsigned int flags, Client *&client)
 

Protected Member Functions

void HandleDeathEvent (MsgEntry *me, Client *notused)
 
void HandleLootItem (MsgEntry *me, Client *client)
 

Protected Attributes

CacheManagercacheManager
 
psDatabasedatabase
 
EntityManagerentityManager
 
GEMSupervisorgem
 
csHash< LootEntrySet * > looting
 
LootRandomizerlootRandomizer
 
csHash< SpawnRule * > rules
 

Additional Inherited Members

- Public Types inherited from MessageManager< SpawnManager >
typedef void(SpawnManager::* FunctionPointer) (MsgEntry *, Client *)
 

Detailed Description

This class is periodically called by the engine to ensure that monsters (and other NPCs) are respawned appropriately.

Definition at line 283 of file spawnmanager.h.

Constructor & Destructor Documentation

SpawnManager::SpawnManager ( psDatabase db,
CacheManager cachemanager,
EntityManager entitymanager,
GEMSupervisor gemsupervisor 
)
virtual SpawnManager::~SpawnManager ( )
virtual

Member Function Documentation

LootRandomizer* SpawnManager::GetLootRandomizer ( )
inline

Returns the loot randomizer.

Returns
Returns a reference to the current loot randomizer.

Definition at line 307 of file spawnmanager.h.

void SpawnManager::HandleDeathEvent ( MsgEntry me,
Client notused 
)
protected
void SpawnManager::HandleLootItem ( MsgEntry me,
Client client 
)
protected
void SpawnManager::KillNPC ( gemActor npc,
gemActor killer 
)

Sets the NPC as dead, plays the death animation and triggers the loot generator.

Also queues the removal of the corpse.

void SpawnManager::LoadHuntLocations ( psSectorInfo sectorinfo = 0)

Load hunt location.

Parameters
sectorinfoThe sector to load in. NULL means all sectors.
void SpawnManager::LoadSpawnRanges ( SpawnRule rule)

Load all ranges for a rule.

void SpawnManager::PreloadDatabase ( )

Load all rules into memory for future use.

void SpawnManager::PreloadLootRules ( )

Load all loot categories into the manager for use in spawn rules.

void SpawnManager::RemoveNPC ( gemObject obj)

Kills the specified NPC, updates the database that he is "dead" and queues him for respawn according to the spawn rules.

void SpawnManager::RepopulateItems ( psSectorInfo sectorinfo = 0)

Adds all items to the world.

Called at the server startup to add all the items to the game.

Parameters
sectorinfoThe sector to respawn the items into. If NULL it will respawn all items in all sectors.
void SpawnManager::RepopulateLive ( psSectorInfo sectorinfo = 0)

Called at server startup to create all creatures currently marked as "living" in the database.

This will restore the server to its last known NPC population if it crashes.

Parameters
sectorinfoThe sector we want to repopulate. If NULL then respawn all sectors.
void SpawnManager::Respawn ( PID  playerID,
SpawnRule spawnRule 
)

Respawn a NPC given by playerID and find the position from the spawnRule.

void SpawnManager::Respawn ( psCharacter chardata,
InstanceID  instance,
csVector3 &  where,
float  rot,
const char *  sector 
)

Respawn a NPC in the given position.

void SpawnManager::SpawnHuntLocations ( Result result,
psSectorInfo sectorinfo 
)

Used by LoadHuntLocations() to spawn the hunt locations in game.

Parameters
resultthe result set to use for the spawm
sectorinfoThe sector to load in. NULL means all sectors.

Member Data Documentation

CacheManager* SpawnManager::cacheManager
protected

Definition at line 290 of file spawnmanager.h.

psDatabase* SpawnManager::database
protected

Definition at line 286 of file spawnmanager.h.

EntityManager* SpawnManager::entityManager
protected

Definition at line 291 of file spawnmanager.h.

GEMSupervisor* SpawnManager::gem
protected

Definition at line 292 of file spawnmanager.h.

csHash<LootEntrySet*> SpawnManager::looting
protected

Definition at line 288 of file spawnmanager.h.

LootRandomizer* SpawnManager::lootRandomizer
protected

Definition at line 289 of file spawnmanager.h.

csHash<SpawnRule*> SpawnManager::rules
protected

Definition at line 287 of file spawnmanager.h.


The documentation for this class was generated from the following file: