ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
best strategy for script-spawning many game objects

Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  11:44:22  11 July 2013
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519
best strategy for script-spawning many game objects

Hi!

In the past I did lots of script-spawning, mainly NPCs and mutants, but also objects such as cars or weapons, and of course level changers.

The problem: Spawning game objects by script is slow and memory demanding, and limited by X-Ray. For example, populating an empty level with 40 NPCs upon first load takes about one minute on my system. Numbers much larger than that (e.g. over 100 NPCs) will make the game crash after flooding the RAM.

Of course I know the intended way to populate entire maps would be all.spawn, but for the sake of mod portability I need script spawning instead (my mods won't be "pluggable" into existing mods when using all.spawn).

So, are there any good strategies to spawn large numbers of objects by script without running into these X-Ray limitations?
  15:11:13  11 July 2013
profilee-mailreply Message URLTo the Top
bamah
Senior Resident
 

 
On forum: 02/10/2008
 

Message edited by:
bamah
07/11/2013 15:13:21
Messages: 911
Spawns

Why not just use timer spawning or conditional, even just actor level loading only vs game load It woulds stagger the load instead of doing the spawns on game_load()

Use blowout to spawn stuff as it's timer is already running, weapons, items, npcs, mob.

Add stuff you want in game via boxes in xr_box.script.

Nanderson's random stashes can add new items to the game randomly

When freeplay starts call a script function to spawn unique NPCs game wide. I spawn legends of the zone like Ghost, Fang, Doc etc. with and without existing smarts via custom data script.

ThunderFreaks attack spawns are customizable. I have US special forces randomly appear with a random math timer. They're like Monolith everyone hates them.

The zombie conversion from npcss in zombie shooter mod. I have about 15 different zombies that can spawn from about 35% of dead npcs. It needed a random timer or just about all npcs converted immediately. Now it's random time and random possibility.

This one is more involved but interesting
A good conditional is when key npcs die they trigger a spawn...say wolf dies it triggers a Merc attack on cordon.

ogsm_respawn.script is good also. I know you've looked at that.
Look at dream reader mod for some per level spawning
This stuff is all modular!
  15:21:41  11 July 2013
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519
Wow, thanks quite a bunch of good ideas and hints! Thanks
  17:23:47  11 July 2013
profilee-mailreply Message URLTo the Top
insanelazarez
Yeah, Good Luck With That...
(Resident)

 

 
On forum: 01/31/2009
Messages: 1070
Just an opinion...


---QUOTATION---
best strategy for script-spawning many game objects

Hi!

In the past I did lots of script-spawning, mainly NPCs and mutants, but also objects such as cars or weapons, and of course level changers.

The problem: Spawning game objects by script is slow and memory demanding, and limited by X-Ray. For example, populating an empty level with 40 NPCs upon first load takes about one minute on my system. Numbers much larger than that (e.g. over 100 NPCs) will make the game crash after flooding the RAM.

Of course I know the intended way to populate entire maps would be all.spawn, but for the sake of mod portability I need script spawning instead (my mods won't be "pluggable" into existing mods when using all.spawn).

So, are there any good strategies to spawn large numbers of objects by script without running into these X-Ray limitations?
---END QUOTATION---



Meltac, if you want to spawn such number of npcs... stay away from scripts. If the map is empty, you have the perfect conditions to build a stable game. Use the all.spawn... it's just copy and paste, man. All.spawn is time consuming, that is true... if you don't like to use it. For me spawning by script is time consuming (among other things), because i don't like it.

Some advices if you don't mind.

All.spawn:

1 - Try to limit the npcs created with a spawning condition. It is better for you to spawn the npcs from the start.

2 - One of the parameters in all.spawn is 'object_flags'. The stalkers from military waves (and sniper monoliths) in npp use 'object_flags = 0xfffffffb'. It's used to keep npcs online no matter what the distance is. Stay away from this specific flag. Use 'object_flags = 0xffffffbf' instead... because this way the game 'respects' the 150 metters rule.

3- Using the second flag i said has another big advantage... when you use a spawn condition. You can vanish the stalker if you want, by disabling the condition itself. And then if you want to spawn him again call the info portion again. The second spawn is created in the position where the first instance vanished the first time. Doctor npc has a different flag 'object_flags = 0xffffffff' but the result is the same. After the crappy scripted scene ends... the npc himself disables himself... literally:


---QUOTATION---


[spawner]
cond = {+agr_doc_wakeup} ;STALKER CREATED HERE

[smart_terrains]
none = true

[logic]
active = remark@idle
combat_ignore = combat_ignore

[remark@idle]
anim = wait
on_info = {+agr_doc_wakeup} remark@anim
combat_ignore_cond = always
meet = no_meet

[remark@anim]
anim = doctor_wakeup
combat_ignore_cond = always
on_signal = anim_end | %-agr_doc_wakeup% ;STALKER VANISHED
meet = no_meet



---END QUOTATION---



Example

[link]http://www.youtube.com/watch?v=0MlgqewaA5Q[/link]

The same thing happens with Doctor npc. But you can't do the same with npp military nor monoliths. Because once in game... they can not vanish by disabling spawn condition. This is a good trick, because allow us to observe that specific group fighting the enemy even if you are 1000 metters away. The rpg helicopter hunters, right? Impossible to forget them.

Script:

1 - Well, i use scripts to simple things. Like if i want to execute a simple function to create a medkit, a pistol, only in a specific moment... yes. But not for creating a bunch of npcs.

2- If you still want spawning by script make sure your 'alife create' thing includes 'game_vertex_id' and 'level_vertex_id'. But this is not going to help you if you want a stable mod.

Btw, merging two mods in some cases might be tricky. But the same way you merge scripts you can do the same with all.spawn.

Imagine these two mods:

Meltac mod - 40 npcs

Insanelazarez Mod - 40 npcs

Nothing is going to change the fact that you going to create 80 npcs.
By all.spawn it works ok. By script? 'Ay Pobrecito'.


Well, meltac... this is just an opinion.
  18:05:52  11 July 2013
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
 

Message edited by:
Meltac
07/11/2013 18:06:13
Messages: 1519
Well, insanelazarez I know you're not the born scripter (no offense)

You like messing with all.spawn - that's ok. I don't.

I don't talk about mod merging in the classical way, I'm talking about making mods that easy plug into existing ones, thus without merging. That's something different. And this can't be achieved using the all.spawn, only using scripts.

Nonetheless, I truly see the big advantages of all.spawn. It's just, that's not what I'm after. For me, the advantages of scripting outbalance those of using the all.spawn - I'm a coder, not a "configurator"

But thanks for your opinion.
 
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-2021 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.