28 #include <csutil/hash.h> 57 struct iCollideSystem;
64 #define NPC_BRAIN_TICK 200 70 #define NPCDebug(npc,debug,...) \ 71 { if (npc->IsDebugging()) { npc->Printf(debug, __VA_ARGS__); }} 85 this->npcclient = npcclient;
86 this->engine = engine;
91 void AddHate(EID entity_id,
float delta);
110 bool includeOutsideRegion,
bool includeInvisible,
bool includeInvincible,
float* hate);
111 bool Remove(EID entity_id);
112 void DumpHateList(csString &output,
const csVector3 &myPos, iSector* mySector);
113 void DumpHateList(
NPC* npc,
const csVector3 &myPos, iSector* mySector);
150 LOCATION_RADIUS = 16,
151 LOCATION_TARGET = 32,
221 void Advance(csTicks when);
226 void TickPostProcess(csTicks when);
252 uint8_t
GetDRCounter(csTicks when,
const csVector3 &pos,
float yRot, iSector* sector,
253 const csVector3 &vel,
float angVel)
256 lastDrPosition = pos;
257 lastDrSector = sector;
260 lastDrAngVel = angVel;
273 bool Load(iResultRow &row,csHash<NPCType*, const char*> &npctypes,
EventManager* eventmanager, PID usePID);
278 void Load(
const char* name, PID pid,
NPCType* type,
const char* region_name,
int debugging,
bool disabled,
EventManager* eventmanager);
282 bool InsertCopy(PID use_char_id, PID ownerPID);
295 return name.GetDataSafe();
297 void SetAlive(
bool a);
302 void Disable(
bool disable =
true);
324 void ScopedTimerCallback(
const ScopedTimer* timer);
332 csString Info(
const csString &infoRequestSubCmd);
345 void DumpState(csString &output);
350 void DumpBehaviorList(csString &output);
355 void DumpReactionList(csString &output);
370 void DumpDebugLog(csString &output);
375 void DumpMemory(csString &output);
380 void DumpControlled(csString &output);
404 void TriggerEvent(
Perception* pcpt,
float maxRange=-1.0,
405 csVector3* basePos=NULL, iSector* baseSector=NULL,
406 bool sameSector=
false);
415 void TriggerEvent(
const char* pcpt);
420 return last_perception;
436 bool includeInvincible,
float* hate=NULL);
454 bool includeInvisible,
bool includeInvincible,
float* hate);
471 void AddToHateList(
gemNPCActor* attacker,
float delta);
476 void RemoveFromHateList(EID who);
481 void SetLocate(
const csString &destination,
const NPC::Locate &locate);
486 void GetActiveLocate(csVector3 &pos, iSector* §or,
float &rot);
493 void GetActiveLocate(
Waypoint* &wp);
500 float GetActiveLocateRadius()
const;
507 bool CopyLocate(csString source, csString destination,
unsigned int flags);
514 void ReplaceLocations(csString &result);
519 float GetAngularVelocity();
529 float GetWalkVelocity();
534 float GetRunVelocity();
558 insideRegion = inside;
571 gemNPCActor* GetNearestActor(
float range, csVector3 &destPosition, iSector* &destSector,
float &destRange);
582 gemNPCActor* GetNearestNPC(
float range, csVector3 &destPosition, iSector* &destSector,
float &destRange);
593 gemNPCActor* GetNearestPlayer(
float range, csVector3 &destPosition, iSector* &destSector,
float &destRange);
602 void AddAutoMemorize(csString types);
607 void RemoveAutoMemorize(csString types);
614 return !autoMemorizeTypes.IsEmpty();
620 bool ContainAutoMemorizeType(
const csString &type);
626 virtual void LocalDebugReport(
const csString &debugString);
631 virtual void RemoteDebugReport(uint32_t clientNum,
const csString &debugString);
638 const char* GetOwnerName();
648 void SetOwner(EID owner_EID);
653 void SetTribe(
Tribe* new_tribe);
665 void SetTribeMemberType(
const char* tribeMemberType);
669 const csString &GetTribeMemberType()
const;
677 return insideTribeHome;
687 insideTribeHome = inside;
704 float GetMaxHP()
const;
709 float GetHPRate()
const;
719 float GetMaxMana()
const;
724 float GetManaRate()
const;
729 float GetPysStamina();
734 float GetMaxPysStamina()
const;
739 float GetPysStaminaRate()
const;
744 float GetMenStamina();
749 float GetMaxMenStamina()
const;
754 float GetMenStaminaRate()
const;
769 void UpdateControlled();
774 void CheckPosition();
782 void StoreSpawnPosition();
787 const csVector3 &GetSpawnPosition()
const;
792 iSector* GetSpawnSector()
const;
823 csString GetBuffer(
const csString &bufferName);
831 void SetBuffer(
const csString &bufferName,
const csString &value);
838 void ReplaceBuffers(csString &result);
873 virtual double CalcFunction(
MathEnvironment* env,
const char* functionName,
const double* params);
874 virtual const char* ToString();
882 iCollideSystem* cdsys;
884 BufferHash npcBuffer;
psWorld is in charge of managing all regions (zone map files) and loading/unloading them as needed...
virtual csString ToString() const
Return a string with information about the event.
This embodies any perception an NPC might have, or any game event of interest.
Check how long time it take to process a scope.
psNPCClient * npcclient
Global connection to the NPC Client.
This object represents the entities which have attacked or hurt the NPC and prioritizes them...
Callback function for ScopedTimers.
A specific MathEnvironment to be used in a MathScript.
iSector * spawnSector
The stored sector that this NPC where spawned.
csHash< Locate *, csString > LocateHash
HateList(psNPCClient *npcclient, iEngine *engine, psWorld *world)
csString tribeMemberType
What type/class is this NPC in the tribe.
bool IsInsideTribeHome()
Check the inside tribe home state of the npc.
bool IsInsideRegion()
Check the inside region state of the npc.
iSector * sector
The sector for the located object.
bool insideTribeHome
State variable for inside outside tribe home checks.
Structure to hold located positions.
csArray< csString > autoMemorizeTypes
Used to store what types of perceptions to memorize without changing behaviors.
Perception * last_perception
Perception * GetLastPerception()
void SetInsideTribeHome(bool inside)
Set the inside tribe home state.
A set of operations building a generic behavior for a NPC.
void SetInsideRegion(bool inside)
Set the inside region state.
A waypoint is a specified circle on the map with a name, location, and a list of waypoints it is conn...
Represents a stat for the NPC.
Handle all network messages inn and out of the NPC Client.
const char * GetOrigBrainType()
void AddHate(EID entity_id, float delta)
This stores a vector of positions listing a set of points defining a common type of location...
int GetFallCounter()
Return the fall counter.
LocateHash storedLocates
List of stored locate locations.
virtual void Trigger()
Abstract event processing function.
csString origtype
Name of NPCType for 'reload'.
The event that makes the NPC brain go TICK.
void IncrementFallCounter()
Increment the fall counter.
psNPCTick(int offsetticks, NPC *npc)
This object represents each NPC managed by this superclient.
float radius
The radius of the located object.
csHash< csString, csString > BufferHash
float angle
The angle of the located object.
The main NPC Client class holding references to important superclient objects.
NPCType * oldbrain
delete at checkpoint
LocationType * region
Cached pointer to the region.
Locate * activeLocate
The current "Active" locate.
float scale
Model scale value.
A collection of behaviors and reactions will represent a type of npc.
csVector3 pos
The position of the located object.
bool HasAutoMemorizeTypes() const
Check if the NPC has anything to automemorize.
gemNPCActor * GetMostHated(NPC *npc, csVector3 &pos, iSector *sector, float range, LocationType *region, bool includeOutsideRegion, bool includeInvisible, bool includeInvincible, float *hate)
Find the most hated entity within range of given position.
Keep track of remote debugging.
void SetDRCounter(uint8_t counter)
csArray< csWeakRef< gemNPCActor > > controlledActors
Actors that are dragged/pushed around by this NPC.
csHash< HateListEntry *, EID > hatelist
uint8_t GetDRCounter(csTicks when, const csVector3 &pos, float yRot, iSector *sector, const csVector3 &vel, float angVel)
csWeakRef< gemNPCObject > target
The located target.
bool Remove(EID entity_id)
void DumpHateList(csString &output, const csVector3 &myPos, iSector *mySector)
psNPCRaceListMessage::NPCRaceInfo_t * raceInfo
All scheduled events must inherit from this class.
Waypoint * wp
The nearest waypoint to the located object.
csString & GetRegionName()
csVector3 spawnPosition
The stored position that this NPC where spawned.
This class handles all queueing and invoking of timed events, such as combat, spells, NPC dialog responses, range weapons, or NPC respawning.
csString region_name
Region name as loaded from db.
bool insideRegion
State variable for inside outside region checks.
Tribe::Memory * GetBufferMemory()
Retrive the current buffer memory of the npc.
Holds list of tribe members, position of tribe home Keeps resources and handles tribe perceptions...