NpcClientStartup: Difference between revisions
Created page with 'On startup the NPC Client will cache various bits of data. LoadNPCTypes(const char* xmlfile) This loads all the data in ''data/npcbehave.xml'' and builds '''NPCType''' for …' |
No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
On startup the NPC Client will cache various bits of data. | On startup the NPC Client will cache various bits of data. The process starts in psNPCClient::Initialize(), which then calls: | ||
LoadNPCTypes(const char* xmlfile) | LoadNPCTypes(const char* xmlfile) | ||
This loads all the data in | This loads all the data in database and builds '''NPCType''' for each one. These are stored in the the psNPCClient.npctypes array. | ||
ReadNPCsFromDatabase() | ReadNPCsFromDatabase() | ||
This reads all the data from the [[sc_npc_definitionsTable|sc_npc_definitions]] table and will create a new '''NPC''' object for each of them. They are stored inside the psNPCClient.npcs array. | This reads all the data from the [[sc_npc_definitionsTable|sc_npc_definitions]] table and will create a new '''NPC''' object for each of them. They are stored inside the psNPCClient.npcs array. This function also starts the Tick() of the NPC brain. | ||
Line 15: | Line 15: | ||
Should note that none of the entities are created though, just their NPC objects. When entities are sent from the server to the npcclient it will attach the NPC to those entities. | Should note that none of the entities are created though, just their NPC objects. When entities are sent from the server to the npcclient it will attach the NPC to those entities. | ||
NPC::Tick() | |||
-> checks the NPC is enabled, | |||
-> calls NPC::Advance() | |||
-> creates a new psNPCTick with a time of 200 milliseconds, this function just calls NPC::Tick() again | |||
NPC::Advance() | |||
-> calls NPCType::Advance(), which just calls BehaviorSet::Advance() | |||
-> calls UpdateControlled(), which updates the position of the entities controlled by this brain | |||
BehaviorSet::Advance() | |||
-> calls BehaviorSet::UpdateNeeds() which updates the list of needs based on time to increase or decrease the "desire" for that need | |||
-> for the active behaviour calls Behavior::Advance() | |||
-> calls BehaviorSet::Execute() which calls BehaviorSet::Schedule() to rearrange the behaviours based on need, set the new active behaviour if needed and stops previous one, then calls Behavior::StartScript() to start the new Behaviour. | |||
Behavior::Advance() | |||
-> checks if the current script is ready to run or interrupted, then it calls XXXOperation::Run() | |||
-> checks if the current script is already running, then it calls XXXOperation::Advance() , note some Operations do not have an Advance method as those are atomic. | |||
[[Category:Engine documents]] |
Latest revision as of 13:55, 12 June 2018
On startup the NPC Client will cache various bits of data. The process starts in psNPCClient::Initialize(), which then calls:
LoadNPCTypes(const char* xmlfile)
This loads all the data in database and builds NPCType for each one. These are stored in the the psNPCClient.npctypes array.
ReadNPCsFromDatabase()
This reads all the data from the sc_npc_definitions table and will create a new NPC object for each of them. They are stored inside the psNPCClient.npcs array. This function also starts the Tick() of the NPC brain.
It also loads up the tribe and path information.
Should note that none of the entities are created though, just their NPC objects. When entities are sent from the server to the npcclient it will attach the NPC to those entities.
NPC::Tick()
-> checks the NPC is enabled,
-> calls NPC::Advance()
-> creates a new psNPCTick with a time of 200 milliseconds, this function just calls NPC::Tick() again
NPC::Advance()
-> calls NPCType::Advance(), which just calls BehaviorSet::Advance()
-> calls UpdateControlled(), which updates the position of the entities controlled by this brain
BehaviorSet::Advance()
-> calls BehaviorSet::UpdateNeeds() which updates the list of needs based on time to increase or decrease the "desire" for that need
-> for the active behaviour calls Behavior::Advance()
-> calls BehaviorSet::Execute() which calls BehaviorSet::Schedule() to rearrange the behaviours based on need, set the new active behaviour if needed and stops previous one, then calls Behavior::StartScript() to start the new Behaviour.
Behavior::Advance()
-> checks if the current script is ready to run or interrupted, then it calls XXXOperation::Run()
-> checks if the current script is already running, then it calls XXXOperation::Advance() , note some Operations do not have an Advance method as those are atomic.