• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Help understanding NPC Files and spawning

Pavinski

Member
Joined
May 28, 2020
Messages
30
Reaction score
5
Hello,

I just started working with OTS and have a few questions regarding NPC's. I am using OTServBR-global, but my questions are more general.

  • I see each NPC has a xml file with the NPC details and a lua file with its behavior. I also see there is a file that maps NPC name to a number (data/lib/tables/npc_spawn_list.lua) and a file that spawn the NPC's in a loop (data/globalevents/scripts/spawn/npcs_spawn.lua). However I am having trouble finding where the link from the NPC spawned to the NPC xml/lua files is. Can someone help me understand this?

  • If I want multiple NPC's of the same "type" would I just add more NPC's to the npc_spawn_list.lua and give it the same name? Like for example if i want 2 Rashids in different positions would I just do someting like this:
    • [671] = {name = "rashid", pos = {x=31887,y=33101,z=7}},
    • [672] = {name = "rashid", pos = {x=35000,y=33000,z=7}},

  • Can someone explain to me how NPC's like Yasir and Rashid change locations? I see in the code that they are created depending on the day of the week, but how does the game avoid duplicates? I did not see any "de-spawn" code, but I may have missed something. My first thought was it was done with the master position, but I could not back up that statement

  • Any additional information on NPC's is also welcomed

Thank you in advance for the help!
 
Solution
E
If I want multiple NPC's of the same "type" would I just add more NPC's to the npc_spawn_list.lua and give it the same name? Like for example if i want 2 Rashids in different positions would I just do someting like this:
  • [671] = {name = "rashid", pos = {x=31887,y=33101,z=7}},
  • [672] = {name = "rashid", pos = {x=35000,y=33000,z=7}},
yes

Can someone explain to me how NPC's like Yasir and Rashid change locations? I see in the code that they are created depending on the day of the week, but how does the game avoid duplicates? I did not see any "de-spawn" code, but I may have missed something. My first thought was it was done with the master position, but I could not back up that statement
they are created on server...
If I want multiple NPC's of the same "type" would I just add more NPC's to the npc_spawn_list.lua and give it the same name? Like for example if i want 2 Rashids in different positions would I just do someting like this:
  • [671] = {name = "rashid", pos = {x=31887,y=33101,z=7}},
  • [672] = {name = "rashid", pos = {x=35000,y=33000,z=7}},
yes

Can someone explain to me how NPC's like Yasir and Rashid change locations? I see in the code that they are created depending on the day of the week, but how does the game avoid duplicates? I did not see any "de-spawn" code, but I may have missed something. My first thought was it was done with the master position, but I could not back up that statement
they are created on server start, so every server save there will be a new position, that is why there are no duplicates nor need to despawn

and also you could still add npcs the old way by using the spawns.xml file, there is no need to worry about this useless and non sense npc_spawn_list.lua it was made just to make things more complicated than they should be
 
Solution
yes


they are created on server start, so every server save there will be a new position, that is why there are no duplicates nor need to despawn

and also you could still add npcs the old way by using the spawns.xml file, there is no need to worry about this useless and non sense npc_spawn_list.lua it was made just to make things more complicated than they should be

Thank you!

So all it does is update the location, not create a new one. Is this done with the SetMasterPos? Or how is this achieved?
 
Thank you!

So all it does is update the location, not create a new one. Is this done with the SetMasterPos? Or how is this achieved?
it is achieved by this code:

every time the server restart it will create rashid in a new position
 
Back
Top