19 #ifndef __NPCCLIENT_H__ 20 #define __NPCCLIENT_H__ 24 #include <csutil/csstring.h> 25 #include <csutil/hash.h> 26 #include <csutil/ref.h> 27 #include <csutil/list.h> 28 #include <iutil/vfs.h> 30 struct iObjectRegistry;
32 struct iConfigManager;
33 struct iCollideSystem;
47 #include "tools/celhpf.h" 76 struct iCelHNavStruct;
118 bool Initialize(iObjectRegistry* object_reg,
const char* host,
const char* user,
const char* pass,
int port);
178 bool LoadMap(
const char* mapfile);
208 Location*
FindRandomLocation(
const char* loctype, csVector3 &pos, iSector* sector,
float range = -1,
float* found_range = NULL);
334 csVector3* basePos=NULL, iSector* baseSector=NULL,
335 bool sameSector=
false);
418 return npcs.GetSize();
432 bool DumpNPC(
const char* pattern);
437 bool InfoNPC(
const char* pattern);
442 void ListAllEntities(
const char* pattern,
bool onlyCharacters =
false);
536 void UpdateTime(
int minute,
int hour,
int day,
int month,
int year);
543 iCelHPath*
ShortestPath(
NPC* npc,
const csVector3 &from, iSector* fromSector,
const csVector3 &goal, iSector* goalSector);
646 csArray<gemNPCObject*>
FindNearbyEntities(iSector* sector,
const csVector3 &pos,
float radius,
bool doInvisible =
false);
658 csArray<gemNPCActor*>
FindNearbyActors(iSector* sector,
const csVector3 &pos,
float radius,
bool doInvisible =
false);
665 csPtr<iDocumentNode>
GetRootNode(
const char* xmlfile);
794 csHash<psNPCRaceListMessage::NPCRaceInfo_t,csString>
raceInfos;
psWorld is in charge of managing all regions (zone map files) and loading/unloading them as needed...
csRef< MsgHandler > msghandler
void Tick()
This does 1 AI calc per Tribe then returns.
void SaveLogSettings()
Used to save the log settings.
This embodies any perception an NPC might have, or any game event of interest.
bool InfoNPC(const char *pattern)
Find one npc and print its current info.
csArray< gemNPCActor * > FindNearbyActors(iSector *sector, const csVector3 &pos, float radius, bool doInvisible=false)
Create a list of all nearby gem actors.
void AddRaceInfo(const psNPCRaceListMessage::NPCRaceInfo_t &raceInfo)
Add a race info to the race info list.
csHash< NPC *, csString > allReactions
Hash of all registered reactions.
Class to hold information regarding aliases for waypoints.
iCelHNavStruct * GetNavStruct()
~psNPCClient()
Cleans up all allocated memory and removes all the players from the world.
bool IsReady()
If a world is ready and loaded this returns true.
static psNPCClient * npcclient
void RegisterReaction(NPC *npc, Reaction *reaction)
Register a reaction for an NPC with the client.
NPC * ReadMasteredNPC(PID char_id, PID master_id)
Clones a master npc to a new npc whith the passed PID.
bool Initialize(iObjectRegistry *object_reg, const char *host, const char *user, const char *pass, int port)
Initialize the superclient.
int GetGameTODYear()
Get the year of the game time of day.
iCollideSystem * GetCollDetSys()
csHash< psNPCRaceListMessage::NPCRaceInfo_t, csString > raceInfos
Information about all the races.
void AttachNPC(gemNPCActor *actor, uint8_t DRcounter, EID ownerEID, PID masterID)
A specific MathEnvironment to be used in a MathScript.
bool LoadPathNetwork()
made public for the networkmanager to call it
void HandleDeath(NPC *who)
Special handling for death notifications from the server is required, to stop behavior scripting...
Keep information about deferred NPCs during loading.
psPathNetwork * pathNetwork
void ListTribes(const char *pattern)
List all tribes matching pattern to console.
void LoadCompleted()
To be called when the the load process is completed.
void SetEntityPos(EID id, csVector3 &pos, iSector *sector, InstanceID instance, bool force=false)
SetEntityPos finds the given ID entity, and updates its position in mesh and linmove.
void ListAllNPCs(const char *pattern)
List all NPCs matching pattern to console.
Location * FindNearestLocation(const char *loctype, csVector3 &pos, iSector *sector, float range=-1, float *found_range=NULL)
This function handles the searching for the specified object type and basically does the work for the...
csPDelArray< gemNPCObject > all_gem_objects
void TriggerEvent(Perception *pcpt, float maxRange=-1.0, csVector3 *basePos=NULL, iSector *baseSector=NULL, bool sameSector=false)
Sends a perception to all npcs.
bool CheckAttachTribes(NPC *npc)
Loop through every tribe and check if this npc is a member.
csArray< DeferredNPC > npcsDeferred
gemNPCObject * FindEntityID(EID eid)
int GetGameTODHour()
Get the hour of the game time of day.
This defines an interface for intercepting commands instead of handling them locally in the server co...
int GetGameTODMinute()
Get the minute of the game time of day.
A waypoint is a specified circle on the map with a name, location, and a list of waypoints it is conn...
iObjectRegistry * GetObjectReg()
Just make iObjectRegistry available to other classes.
void ListPaths(const char *pattern)
List all paths matching pattern to console.
Handle all network messages inn and out of the NPC Client.
gemNPCObject * FindCharacterID(PID pid)
Waypoint * FindRandomWaypoint(const csVector3 &v, iSector *sector, float range=-1, float *found_range=NULL)
This iterates over all waypoints and finds the nearest one.
csPDelArray< Tribe > tribes
gemNPCObject * FindEntityByName(const char *name)
Find named entity.
virtual double CalcFunction(MathEnvironment *env, const char *functionName, const double *params)
csRef< iCelHNavStruct > navStruct
csList< Edge * > FindEdgeRoute(Waypoint *start, Waypoint *end, const psPathNetwork::RouteFilter *filter)
Find the shortest route between waypoint start and stop.
This stores a vector of positions listing a set of points defining a common type of location...
void ListWaypoints(const char *pattern)
List all waypoints matching pattern to console.
bool LoadMap(const char *mapfile)
Load a map into a region.
bool DumpNPC(const char *pattern)
Find one npc and print its current state info.
bool FirePerception(int NPCId, const char *perception)
Fire perception.
NPCType * FindNPCType(const char *npctype_name)
This function handles the searching for the specified NPCType name so that other NPCTypes can subclas...
unsigned int GetTickCounter() const
Retrive the current tick counter.
Class that represents the Recipe Manager of the game.
void ListReactions(const char *pattern)
List all the registered reactions.
csArray< gemNPCObject * > FindNearbyEntities(iSector *sector, const csVector3 &pos, float radius, bool doInvisible=false)
Create a list of all nearby gem objects.
ServerConsole * serverconsole
Manager that manage all locations and location types.
csHash< gemNPCObject *, PID > all_gem_objects_by_pid
LocationManager * GetLocationManager()
Return the location manager of the npcclient.
void UpdateTime(int minute, int hour, int day, int month, int year)
Update with time from server in order to start timed events.
void LoadLogSettings()
Used to load the log settings.
void PerceptProximityTribeHome()
Find all actors that are in a tribe home and percept tribe and actor if it is an NPC.
NPC * FindNPC(EID entid)
Find the NPC* attached to the entity with the specified EID.
void MainLoop()
Load and fork off a new thread for the Server Console.
MathScriptEngine * mathScriptEngine
LocationType * FindRegion(const char *regname)
Find a region with a given name.
void PerceptProximityLocations()
Find all locations that are close to NPC's and percept the NPC.
float GetRunVelocity(csString &race)
Find the run velocity for a given race.
csArray< gemNPCItem * > all_gem_items
A reaction embodies the change in desire which occurs in an NPC when he perceives something...
virtual const char * ToString()
void EnableDisableNPCs(const char *pattern, bool enable)
Enable or disable NPCs.
This object represents each NPC managed by this superclient.
int GetGameTODDay()
Get the day of the game time of day.
csArray< csString > notUsedReactions
List of not matched reactions.
void Remove(gemNPCObject *object)
psPath * FindPath(const char *name)
Find a given path.
bool LoadTribes()
Load Tribes from the DB.
int current_long_range_perception_index
Counters used to distribute load regarding perception generation.
bool LoadLocations()
Load locations from the DB.
csRef< iConfigManager > configmanager
virtual double GetProperty(MathEnvironment *env, const char *ptr)
psNPCRaceListMessage::NPCRaceInfo_t * GetRaceInfo(const char *name)
Get pointer to a race info to the given race name.
The main NPC Client class holding references to important superclient objects.
csList< Waypoint * > FindWaypointRoute(Waypoint *start, Waypoint *end, const psPathNetwork::RouteFilter *filter)
Find the shortest route between waypoint start and stop.
This class is implements the user input and output console for the server.
Waypoint * FindWaypoint(gemNPCObject *entity)
This iterates over all waypoints and finds the one the entity is at.
bool AddNPCType(csString newType)
Add an NPCType.
int GetGameTODMonth()
Get the month of the game time of day.
void ListAllEntities(const char *pattern, bool onlyCharacters=false)
List all known entities on superclient.
csPtr< iDocumentNode > GetRootNode(const char *xmlfile)
Load and return the root node of an xml file.
This class is the client's and server's main interface for either sending network messages out or get...
psNetConnection * GetNetConnection()
Returns the network handler so script ops can invoke the network.
bool ReadNPCsFromDatabase()
Read NPCs from the DB.
size_t GetNpcListAmount()
List the amount of npc currently loaded.
iCelHPath * ShortestPath(NPC *npc, const csVector3 &from, iSector *fromSector, const csVector3 &goal, iSector *goalSector)
A collection of behaviors and reactions will represent a type of npc.
csArray< gemNPCActor * > all_gem_actors
void ListTribeRecipes(const char *tribeID)
List all the active recipes in a tribe.
csHash< gemNPCObject *, EID > all_gem_objects_by_eid
void Add(gemNPCObject *object)
int current_long_range_perception_loc_index
unsigned int tick_counter
Counter used to start events at every nth client tick.
csRef< iCollideSystem > cdsys
EventManager * eventmanager
float GetWalkVelocity(csString &race)
Find the walk velocity for a given race.
bool DumpRace(const char *pattern)
Dump all race infos.
void Disconnect()
Disconnect from server nicely, before quitting.
EventManager * GetEventManager()
Returns the Event Manger.
void ListLocations(const char *pattern)
List all locations matching pattern to console.
MathScriptEngine * GetMathScriptEngine()
Returns the Math Scripting Engine.
int current_tribe_home_perception_index
virtual void CatchCommand(const char *cmd)
Catch a command from the console.
psNetConnection * connection
LocationType * FindLocation(const char *locname)
Find a location with a given name.
LocationManager * locationManager
The manager for location.
bool LoadNPCTypes()
Load NPC Types from DB.
This holds all the formulas loaded from the MathScript table and provides a container for them...
NPC * FindNPCByPID(PID character_id)
Find the NPC* attached to the entity with the specified character ID.
Template class for implementing waypoint filtering when calculating routes.
A Location is a named place on the map, located dynamically by NPCs as scripted.
A network of Waypoint and psPath objects.
csHash< NPCType *, const char * > npctypes
NetworkManager * GetNetworkMgr()
Returns the network handler so script ops can invoke the network.
Waypoint * FindNearestWaypoint(const csVector3 &v, iSector *sector, float range=-1, float *found_range=NULL)
This iterates over all waypoints and finds the nearest one.
void AttachObject(iObject *object, gemNPCObject *gobject)
Attach a server gemObject to a Crystal Space object.
Location * FindRandomLocation(const char *loctype, csVector3 &pos, iSector *sector, float range=-1, float *found_range=NULL)
This function handles the searching for the specified object type and basically does the work for the...
This class handles all queueing and invoking of timed events, such as combat, spells, NPC dialog responses, range weapons, or NPC respawning.
gemNPCObject * FindAttachedObject(iObject *object)
See if there is a gemObject attached to a given Crystal Space object.
Tribe * GetTribe(int id)
Make a tribe pointer available - for the network manager.
NPC * ReadSingleNPC(PID char_id, PID master_id=0)
void UnattachObject(iObject *object, gemNPCObject *gobject)
Unattach a gemObject from a Crystal Space object.
psPathNetwork * GetPathNetwork()
Return the path network of the npcclient.
Holds list of tribe members, position of tribe home Keeps resources and handles tribe perceptions...
psNPCClient()
Constructor.
RecipeManager * recipemanager
void PerceptProximityItems()
Find all items that are close to NPC's and percept the NPC.