Planeshift
SpawnRule Class Reference

This class is used to store respawn rules for NPCs. More...

#include <spawnmanager.h>

Public Member Functions

void AddRange (SpawnRange *range)
 Add a spawn range to current rule. More...
 
PID CheckSubstitution (PID originalplayer)
 Determine if substitute player should be spawned. Returns either original or substitute. More...
 
bool DetermineSpawnLoc (psCharacter *ch, csVector3 &pos, float &angle, csString &sectorname, InstanceID &instance)
 Pick a spot for the entity to respawn. More...
 
int GetDeadRemainTime ()
 
int GetID ()
 
LootEntrySetGetLootRules ()
 Get the Loot Rule set to generate loot. More...
 
int GetMinSpawnSpacingDistance ()
 
int GetRespawnDelay ()
 Get random value between min and max spawn time, in ticks/msecs. More...
 
void Initialize (int idval, int minspawn, int maxspawn, float substodds, int substplayer, float x, float y, float z, float angle, const char *sector, LootEntrySet *loot_id, int dead_time, float minSpacing, InstanceID instance)
 Setup variables. More...
 
void SetID (int idval)
 
 SpawnRule ()
 Ctor clears all to zero. More...
 
 ~SpawnRule ()
 

Protected Attributes

int dead_remain_time
 
InstanceID fixedinstance
 
float fixedspawnrot
 
csString fixedspawnsector
 
float fixedspawnx
 If ranges are populated, these are ignored. More...
 
float fixedspawny
 
float fixedspawnz
 
int id
 Unique Id used for ident and tree sorting. More...
 
LootEntrySetloot
 Rules for generating loot when this npc is killed. More...
 
int maxspawntime
 Maximum respawn delay in ticks. More...
 
float minSpawnSpacingDistance
 What should the free space be around before spawn position is accepted. More...
 
int minspawntime
 Minimum respawn delay in ticks (msec) More...
 
csRandomGen * randomgen
 
csHash< SpawnRange * > ranges
 Spawn ranges for the current rule. More...
 
PID substituteplayer
 Player id to respawn if substitution spawn odds are met. More...
 
float substitutespawnodds
 Odds of substitute spawn triggering instead of respawn of same entity. More...
 

Detailed Description

This class is used to store respawn rules for NPCs.

They are loaded from the database at startup and used only in RAM thereafter.

Definition at line 118 of file spawnmanager.h.

Constructor & Destructor Documentation

SpawnRule::SpawnRule ( )

Ctor clears all to zero.

SpawnRule::~SpawnRule ( )

Member Function Documentation

void SpawnRule::AddRange ( SpawnRange range)

Add a spawn range to current rule.

PID SpawnRule::CheckSubstitution ( PID  originalplayer)

Determine if substitute player should be spawned. Returns either original or substitute.

bool SpawnRule::DetermineSpawnLoc ( psCharacter ch,
csVector3 &  pos,
float angle,
csString &  sectorname,
InstanceID instance 
)

Pick a spot for the entity to respawn.

Returns
True if this is a random area rule, or false if it is a fixed position.
int SpawnRule::GetDeadRemainTime ( )
inline

Definition at line 206 of file spawnmanager.h.

int SpawnRule::GetID ( )
inline

Definition at line 175 of file spawnmanager.h.

LootEntrySet* SpawnRule::GetLootRules ( )
inline

Get the Loot Rule set to generate loot.

Definition at line 201 of file spawnmanager.h.

int SpawnRule::GetMinSpawnSpacingDistance ( )
inline

Definition at line 211 of file spawnmanager.h.

int SpawnRule::GetRespawnDelay ( )

Get random value between min and max spawn time, in ticks/msecs.

void SpawnRule::Initialize ( int  idval,
int  minspawn,
int  maxspawn,
float  substodds,
int  substplayer,
float  x,
float  y,
float  z,
float  angle,
const char *  sector,
LootEntrySet loot_id,
int  dead_time,
float  minSpacing,
InstanceID  instance 
)

Setup variables.

void SpawnRule::SetID ( int  idval)
inline

Definition at line 179 of file spawnmanager.h.

Member Data Documentation

int SpawnRule::dead_remain_time
protected

Definition at line 154 of file spawnmanager.h.

InstanceID SpawnRule::fixedinstance
protected

Definition at line 145 of file spawnmanager.h.

float SpawnRule::fixedspawnrot
protected

Definition at line 143 of file spawnmanager.h.

csString SpawnRule::fixedspawnsector
protected

Definition at line 144 of file spawnmanager.h.

float SpawnRule::fixedspawnx
protected

If ranges are populated, these are ignored.

Definition at line 140 of file spawnmanager.h.

float SpawnRule::fixedspawny
protected

Definition at line 141 of file spawnmanager.h.

float SpawnRule::fixedspawnz
protected

Definition at line 142 of file spawnmanager.h.

int SpawnRule::id
protected

Unique Id used for ident and tree sorting.

Definition at line 125 of file spawnmanager.h.

LootEntrySet* SpawnRule::loot
protected

Rules for generating loot when this npc is killed.

Definition at line 152 of file spawnmanager.h.

int SpawnRule::maxspawntime
protected

Maximum respawn delay in ticks.

Definition at line 131 of file spawnmanager.h.

float SpawnRule::minSpawnSpacingDistance
protected

What should the free space be around before spawn position is accepted.

Definition at line 146 of file spawnmanager.h.

int SpawnRule::minspawntime
protected

Minimum respawn delay in ticks (msec)

Definition at line 128 of file spawnmanager.h.

csRandomGen* SpawnRule::randomgen
protected

Definition at line 122 of file spawnmanager.h.

csHash<SpawnRange*> SpawnRule::ranges
protected

Spawn ranges for the current rule.

Definition at line 149 of file spawnmanager.h.

PID SpawnRule::substituteplayer
protected

Player id to respawn if substitution spawn odds are met.

Definition at line 137 of file spawnmanager.h.

float SpawnRule::substitutespawnodds
protected

Odds of substitute spawn triggering instead of respawn of same entity.

Definition at line 134 of file spawnmanager.h.


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