ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
NPC spawn through script question

1 2 3 4 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  18:51:15  12 May 2014
profilee-mailreply Message URLTo the Top
hexef
(Novice)
 
On forum: 05/12/2014
Messages: 26
NPC spawn through script question

So I have created a script which spawns some npcs in some places around the level the player currently is.The problem is that I get flooded with npcs as I play the game(I got like 103 online npcs alive once).

My question is how can I make it so the script spawns for example a maximum of 5 npcs and then in stops executing?And if one of npcs dies,then a replacement is automatically spawned ?Some sort of script that monitors how many npcs I spawned,and checks if they are alive and if 2 of them die for example,the script executes and spawns the 2 missing npcs,without exceeding the npc cap(which is in our case 5 npcs alive at the same time).
  19:51:56  12 May 2014
profilee-mailreply Message URLTo the Top
SacriPan
Senior Resident
 

 
On forum: 09/20/2009
 

Message edited by:
SacriPan
05/12/2014 19:57:02
Messages: 319
Hi,

Instead of having a cap on npc number, you could set a timer so the map isn't filled too quickly with npc.

Take a look at Thunderfreak script to see how it can be done: http://rghost.net/55112646


EDIT:
Otherwise, you can make a counter that would be increased every time you spawn a NPC. Then with a timer, reset the counter to 0 from time to time so NPC can respawn to match the cap. This would be the easiest way to do what you want.

EDIT2:
you might want to upload your script on pastebin (http://pastebin.com/) and put the link here so we can check what you did
  20:38:09  12 May 2014
profilee-mailreply Message URLTo the Top
SacriPan
Senior Resident
 

 
On forum: 09/20/2009
 

Message edited by:
SacriPan
05/12/2014 20:44:23
Messages: 319
OK, use this:

http://rghost.net/55113628


I made the script for you.
I commented out the MOD with "SacriPan! MOD" so you can pinpoint directly the modifications that I've made in the scripts.

Right now, NPC spawn on you. You'll have to edit the position of the spawn, as well as the section of the NPC spawned to suit your requirements.


C'est cadeau!
  21:05:42  12 May 2014
profilee-mailreply Message URLTo the Top
hexef
(Novice)
 
On forum: 05/12/2014
 

Message edited by:
hexef
05/12/2014 21:32:01
Messages: 26
Hey,thanks for your answers,Sacripan ! I'm replying in order of your posts and edits:

I have tried setting a timer and each n seconds a wave of npc spawns and it succesfully works !

I took a look at Thunderfreaks's mod but it is too complex for me and I don't understand (I just got started with Lua scripting on Shoc)

I haven't tried with a counter,but I will !

This is my code:http://pastebin.com/cEXH6qCZ

Thanks for making a script for me ! That means a lot,especially for a scripting newbie like me !


But now before I try your "gift",I have some important questions to address regarding scripting:

-Which is the best .script file to put my custom .script file in?For my custom script I put it inside bind_stalker.script (function actor_binder:update(delta)).I just got inspired from other peoples' work.I still don't know where should I put it to execute better.

-Regarding my custom script,even if I make a counter + a timer to control the npc population from my spawns.If I save the game and then reload,a new generation of npcs spawn and repeating this process will flood my game again with npcs.What I really mean precisely is that even though I put a cap on my spawns,if I save and then load,my script resets everything including the cap and all my variables and npcs will continue to pour out
So,is there a way to actually parse some of the variables inside my function to persist/be bounded with the save game?

Thanks for your patience.
  21:27:19  12 May 2014
profilee-mailreply Message URLTo the Top
bamah
Senior Resident
 

 
On forum: 02/10/2008
Messages: 911
xQD, have a looka t ZRP R4
http://www.metacognix.com/files/stlkrsoc/ZRP_1.07_R4.7z

The _custom_ext_zrp_mm.script is a great example of what you are trying to accomplish.
The bind_stalker script, db script, _dev script and _z script are the scripts you need to look at.
What SacriPan did was great! This is another avenue that's all...hope it does not confuse.
  21:43:57  12 May 2014
profilee-mailreply Message URLTo the Top
hexef
(Novice)
 
On forum: 05/12/2014
Messages: 26
Thanks bamah for your recommandation,I will make sure to take a look over that ZRPish thingie.

I also hope that you don't mind if I come up with some stupid questions.After all,it's my first time scripting in a Stalker game and I need to familiarize with the functions and all sorts.
  21:50:45  12 May 2014
profilee-mailreply Message URLTo the Top
bamah
Senior Resident
 

 
On forum: 02/10/2008
 

Message edited by:
bamah
05/12/2014 21:51:30
Messages: 911
Hey, Thunderfreaks attack spawns are not hard to figure out.
I use them quite a bit and am using them now in LA. You should look at them again.
Also Alundaio is quite good....really good and sometime ago he made a spawner for a guy who was having some major language communication issues with this forum. I no longer have it or would post it for you. Shoot him an email.
Another avenue...is the OGSM 2.3.1 mod. It used a great on game load and timed spawning. The script is ogsm_respawn.scrpt and the timer is in the amk.script. It is loaded and updated through bind_stalker.script.
The variable for the timer is in vars.script
  22:04:56  12 May 2014
profilee-mailreply Message URLTo the Top
SacriPan
Senior Resident
 

 
On forum: 09/20/2009
 

Message edited by:
SacriPan
05/12/2014 22:06:55
Messages: 319
As Bamah said, my approach is only one on the many ways to achieve something like that. Each coder will have his own preferences and style of coding.

My script is very simple when you look at it.
Try to mix it with your script and you should quickly build a functionnal mini-mod


Generally, "bind_stalker.script" is the way to go, but depending on the nature of the needs, it may vary.
For example, in the mod I uploaded for you, I also had to use "xr_death.script" because I found out that a dead NPC would be treated by that particular script, so I catched it there and called my custom script from it.
Maybe I could have used an other one, maybe it's not the best script for this (?!?) ... but it works!



Also, there is no stupid question, and certainly not on a community forum like this one
Don't hesitate to spam questions (in your own threads...), but don't forget about the international nature of this particular community (be patient)
  22:17:04  12 May 2014
profilee-mailreply Message URLTo the Top
hexef
(Novice)
 
On forum: 05/12/2014
 

Message edited by:
hexef
05/12/2014 22:21:24
Messages: 26

---QUOTATION---
As Bamah said, my approach is only one on the many ways to achieve something like that. Each coder will have his own preferences and style of coding.

My script is very simple when you look at it.
Try to mix it with your script and you should quickly build a functionnal mini-mod


Generally, "bind_stalker.script" is the way to go, but depending on the nature of the needs, it may vary.
For example, in the mod I uploaded for you, I also had to use "xr_death.script" because I found out that a dead NPC would be treated by that particular script, so I catched it there and called my custom script from it.
Maybe I could have used an other one, maybe it's not the best script for this (?!?) ... but it works!



Also, there is no stupid question, and certainly not on a community forum like this one
Don't hesitate to spam questions (in your own threads...), but don't forget about the international nature of this particular community (be patient)
---END QUOTATION---



That's cool,I'm looking through your code and it looks simple and it's small but at the same time very powerful I guess .I see what I can do with it now that I'm tinkering with it,thanks a lot.There are some things that I don't understand such as NPC IDs and from what I've seen you made those IDs get stored into the savegame,which is exactly what I wanted.Nice job !
  22:25:40  12 May 2014
profilee-mailreply Message URLTo the Top
SacriPan
Senior Resident
 

 
On forum: 09/20/2009
 

Message edited by:
SacriPan
05/12/2014 22:26:51
Messages: 319
The file "lua_help.script" is also very helpful sometimes

I answered a lot of my own questions by looking in it.
 
Each word should be at least 3 characters long.
Search:    
Search conditions:    - spaces as AND    - spaces as OR   
 
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
 

All short dates are in Month-Day-Year format.


 

Copyright © 1995-2022 GSC Game World. All rights reserved.
This site is best viewed in Internet Explorer 4.xx and up and Javascript enabled. Webmaster.
Opera Software products are not supported.
If any problem concerning the site functioning under Opera Software appears apply
to Opera Software technical support service.