Respawning unique NPCs through all.spawn

Discussions on Modding of S.T.A.L.K.E.R. SoC & Clear Sky

Respawning unique NPCs through all.spawn

Postby Brapped on 28 Mar 2009 09:19

I am trying to respawn unique characters via all.spawn.
I have looked at the thread discussion on this site the K.E.T. started as well as the topic showing examples of spawning NPCs & mutants but still not getting it. I can spawn "one offs" no problem.
I am trying to "respawn" a new faction along with cutout mutants. I have used smart patrol & waypoint tools to get coordinates. If I can get a more concise example and/or explanation of what to do or what to look for that I may have missed , I would be eternally grateful. I've decompiled many spawns from other mods (Oblivion, AMK, etc.) for examples but I'm just not seeing anything different than mine, but a second pair of eyes is always helpful. Here is exactly what I have for a one off in Cordon near the bridge by the rookie village:

[871]
; cse_abstract properties
section_name = stalker
name = esc_stranger101
position = -32.2051658630371,-16.0383529663086,-161.63151550293
direction = 0,0,0

; cse_alife_trader_abstract properties
money = 5000
character_profile = sim_hitman_novice

; cse_alife_object properties
game_vertex_id = 108
distance = 4.90000009536743
level_vertex_id = 245211
object_flags = 0xffffffbf
custom_data = <<END
[smart_terrains]
general_lager = true
END

; cse_visual properties
visual_name = actors\novice\green_stalker_a5

; cse_alife_creature_abstract properties
g_team = 0
g_squad = 0
g_group = 0
health = 1
dynamic_out_restrictions =
dynamic_in_restrictions =

upd:health = 1
upd:timestamp = 0x6365735f
upd:creature_flags = 0x74
upd osition = -32.2051658630371,-16.0383529663086,-161.63151550293
upd _model = 0
upd _torso = 0,0,0
upd:g_team = 0
upd:g_squad = 0
upd:g_group = 0

; cse_alife_monster_abstract properties

Here is my attempt at a respawn version that doesn't produce anything:

[872]
; cse_abstract properties
section_name = respawn
name = esc_stranger_respawn_1 (I've also tried escape_hitman_01)
position = -32.2051658630371,-16.0383529663086,-161.63151550293
direction = 0,0,0

; cse_alife_object properties
game_vertex_id = 108
distance = 5.59999990463257
level_vertex_id = 245211
object_flags = 0xffffff3e
custom_data = <<END
[respawn]
;conditions = 0 (I've tried with info portion trigger also)
respawn_section = hitman_respawn_1,2 (name as it appears in spawn section also changed quantity 5-12)
;max_count = 12
;min_count = 5
max_spawn = 2 (changed quantity 1-5)
idle_spawn = medium (changed frequency as well as decreased spawn time in se_respawn)
END

; cse_shape properties
shapes = shape0
shape0:type = sphere
shape0 ffset = 0,0,0
shape0:radius = 1

; cse_alife_space_restrictor properties
restrictor_type = 0

; se_respawn properties

BTW I can compile & decompile the all.spawn no problem.

Thanks
User avatar
Brapped
New Member
 
Posts: 3
Joined: 26 Mar 2009 19:44

Re: Respawning unique NPCs through all.spawn

Postby EggChen on 29 Mar 2009 01:15

Just about to log off, I'll take a look tomorrow brapped.
User avatar
EggChen
Moderator
 
Posts: 1016
Joined: 13 Sep 2008 00:44
Location: Birmingham, UK

Re: Respawning unique NPCs through all.spawn

Postby NatVac on 29 Mar 2009 13:27

Here are questions outside your direct request:

Are your new stalkers properly supported in places like gamedata\config\misc\smart_terrain_presets.ltx and gamedata\config\creatures\spawn_sections.ltx?

Also, have you looked at other methods, like the wiki's spawn-with-a-script stuff?

Look at the Important Links to Modding Questions and Answers page as well -- too bad you didn't ask the question before the FileFront forum went down...
NatVac
Resident
 
Posts: 152
Joined: 16 Sep 2008 00:13
Location: Texas

Re: Respawning unique NPCs through all.spawn

Postby Brapped on 29 Mar 2009 19:36

Hi NatVac
I am using the Stranger faction (Hitman) from fatrap's r&g mod. In his mod he has all spawning done through script versus through all.spawn. All of the instances of this faction are present in spawn_selection, smart_terrain_preset, general_lager, game_relations, se_respawn. Each time you enter a level the script in escape_tasks triggers the spawning of cutout mutants & strangers. I want to control the population whereby you don't have to kill everything on each level before leaving it to prevent a massive build up. If there is a way to alter the original script I would like to do it that way just the same but I am extremely unknowledgeable about how to do it. I have done several changes to all.spawn as well as my own personal tweaks so I'm sure with some direction I can figure it out.
User avatar
Brapped
New Member
 
Posts: 3
Joined: 26 Mar 2009 19:44

Re: Respawning unique NPCs through all.spawn

Postby audioave10 on 29 Mar 2009 22:10

Welcome!
I also learned from FatRap how to use coordinates and make spawn
changes through escape_tasks and to a lesser degree escape_dialogs.
No all-spawn for me as I know my limitations and I also came to the game a little late. However, there are modders here that can surely
help you...Good Luck!
"Let the Zone take me if I am"
User avatar
audioave10
Senior Resident
 
Posts: 1154
Joined: 14 Sep 2008 01:30
Location: USA

Re: Respawning unique NPCs through all.spawn

Postby NatVac on 31 Mar 2009 14:35

Well, I'm not as knowledgeable on smart terrains as EggChen and barin, but I made the mistake of interrupting EggChen's answer, apparently.

Two things come to mind. One is that you can use a limit to keep the spawns down if you spawn them by script. This is done in The MonoMartyrs Seek Revenge demo; the MonoMartyrs present on a level are checked to make sure the maximum is not exceeded. If you get the archive, check out the on_add_actor() function in _custom_ext_zrp_mm.script.

This results in NPCs with no smart terrain assignment. They will wander the level and get into all kinds of trouble.

The other thing is related to how the respawner stuff works. I think that you need to tell the game there's a need for new entities before it will spawn them. Usually this is done via a smart terrain/gulag that specifies the occupying community (e.g., dolg) and the quantity. When the quantity drops, the game spawns replacements via the respawner.

These guys should be able to make use of your gulag's job assignments.

I don't recall any entries in se_respawn.script as being necessary; the vanilla simMaxCount array is only used by some statistics routines, and then apparently only by the devs in debug mode. I also don't have a "spawn_selection" anything, so that may be specific to the mod(s) you are using.
NatVac
Resident
 
Posts: 152
Joined: 16 Sep 2008 00:13
Location: Texas

Re: Respawning unique NPCs through all.spawn

Postby EggChen on 31 Mar 2009 21:25

NatVac wrote:Well, I'm not as knowledgeable on smart terrains as EggChen and barin, but I made the mistake of interrupting EggChen's answer, apparently.


I bet you are buddy, I'm a hacker!! Don't worry about interrupting my response, it's my bad for not getting around to it. Work has been reassuringly busy in these economic times, and I have not had much free time.

"All work and no play makes Egg a dull boy"....

I'd agree with what Natvac has posted so far, but much of what I "know" about all.spawn is from educated guesses, so you could say I "think I know" how to do it!!

Brapped - Your example looks fine, apart from this part :

shape0 ffset = 0,0,0


I'm guessing it is a forum formatting problem (possibly from GSC where you first posted this) rather than an error, but worth checking anyway. Some other things to consider, and remember these are my thoughts, I'm not 100% on any of it!!

1) I think respawning is limited by capacities of smart terrains as Natvac mentions. To test this, try adding things you know should work, like a monolith spawn. They will spawn and head for their nearest smart terrain, but if you see any between Escape and the Bar, you should know that the spawn is working. If that works, then try the strangers again, but let them share all the terrains in Cordon ("community = stalker, stranger" in all.spawn). Also add them to the gulag script where appropriate.

2) I think respawns are limited by actor proximity. So don't hang around that area waiting to see any, move around, and especially change levels.

3) You need to start a new game every time you change something in all.spawn (I'm sure you know this, but always worth mentioning).

4) Make a crude debug, so you know if it works. Adding a respawn for a hitman novice, but giving him an invalid mesh in the config/gameplay/character_desc_xxxx files should do it. Now when he spawns (and comes online) you will get a crash pointing at the mesh. Maybe call it woohooitworks.ogf!!

Edit: Scripting is by far the most sure fire way of spawning, and it may be worth investigating the MonoMartyr approach instead. I like all.spawn because things are more random (or at least they seem to be).

I have a tweaked version of Fatrap's script that could partially achieve what you want. It does a math.random calculation before spawning, so you could get up to 10 variations of dogs, rats, strangers, or military. You could however remove most of these, giving a reduced chance of spawning strangers in a very crude way.

Code: Select all
elseif level == "l04u_labx18" and has_alife_info("esc_darklab_documents_read") then
   local f = math.random(1,20)
   local spawnf1 = vector():set(-2.04, -14.82, 78.09)
   local spawnf2 = vector():set(39.62, -9.28, 4.30)
   local spawnf3 = vector():set(-44.49, -11.48, -20.69)
   local spawnf4 = vector():set(25.70, -14.82, 71.28)
   if f == 1 then
      alife():create("m_poltergeist_normal_tele", spawnf1, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("m_poltergeist_normal_tele", spawnf2, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("m_poltergeist_normal_tele", spawnf3, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
   elseif f == 2 then
      alife():create("zombie_weak", spawnf1, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("zombie_normal", spawnf2, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("zombie_strong", spawnf3, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("zombie_immortal", spawnf4, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
   elseif f == 3 then
      alife():create("m_tushkano_e", spawnf1, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("m_tushkano_e", spawnf2, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("m_tushkano_e", spawnf3, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("m_tushkano_e", spawnf4, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("m_tushkano_e", spawnf1, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("m_tushkano_e", spawnf2, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("m_tushkano_e", spawnf3, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("m_tushkano_e", spawnf4, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
   elseif f == 4 then
      alife():create("sim_stranger_respawn_3", spawnf1, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
   elseif f == 5 then
      alife():create("sim_stranger_respawn_3", spawnf2, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
   elseif f == 6 then
      alife():create("sim_stranger_respawn_3", spawnf3, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
   elseif f == 7 then
      alife():create("sim_stranger_respawn_3", spawnf4, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
   elseif f == 8 then
      alife():create("gigant_normal", spawnf4, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
       elseif f == 9 then
      alife():create("bloodsucker_normal", spawnf1, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("bloodsucker_strong", spawnf2, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("bloodsucker_normal", spawnf3, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
       elseif f == 10 then
      alife():create("val_bandit_respawn_guard", spawnf1, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("val_bandit_respawn_guard", spawnf2, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
      alife():create("val_bandit_respawn_guard", spawnf3, db.actor:level_vertex_id() , db.actor:game_vertex_id() )
   end
return true


You could comment out as many or as few as you wanted to give a 10%, 20% chance etc. You can also randomise where they spawn in a level.
User avatar
EggChen
Moderator
 
Posts: 1016
Joined: 13 Sep 2008 00:44
Location: Birmingham, UK

Re: Respawning unique NPCs through all.spawn

Postby Brapped on 02 Apr 2009 21:33

To NatVac & EggChen

Sorry for not responding sooner. I want to thank you both for your suggestions. I did d/l "ZRP_MM_AS_Demo_090206" Mod which looks like it has the potential to do what I need it to do. However, being the _custom_ext_zrp_mm.script is unique, how is this file called up in the game or implemented, as I would prefer merging this into what mods I currently use. I feel it would be (hopefully) less difficult to do it that way. If either of you have a moment can you please give me some idea how to do this. I apologize for not being more knowledgeable about these things. Thanks again to everyone who offered their assistance to me. Cheers!
User avatar
Brapped
New Member
 
Posts: 3
Joined: 26 Mar 2009 19:44

Re: Respawning unique NPCs through all.spawn

Postby NatVac on 04 Apr 2009 22:01

The on_add_actor() function in that file is called by the _z.script's on_add_actor(), which in turn is called by db.script's on_add_actor(). You can put stuff like this in that last function in your mod, or in the escape_tasks.script file.

You mainly want the code to prevent excessive spawning. The first loop in that function checks to see how many MonoMartyrs are already in the game. The variable levelMMcount includes the bodies, which go away after four game hours in the demo. The variable levelMMalive counts only the living MonoMartyrs.

Note that the count is compared against the maximum desired for the level. If the count is greater than or equal to that number, limit_reached is set to true.

The second loop then adds new MonoMartyrs to the game if limit_reached is false and the spawn point is sufficiently far away from the Marked One's current location.

The part that calls _dev..queue_item_for_insertion() is just adding the item or NPC to a list for spawning via alife():create() in a deferred manner. This spawning is triggered by bind_stalker.nv_need_update = true so that _dev.do_update() is executed. This function uses the structure of spawn points and limits to create groups of MonoMartyrs at different places in the level if needed.

But you don't need to do any of that stuff in the previous paragraph. You just want to check how many of each special creature or NPC type is already in the game, and then spawn more if it is less than the maximum. If you use the count that includes the bodies, you'll get a breather after killing them all. Otherwise the game will keep topping off your glass, so to speak.
NatVac
Resident
 
Posts: 152
Joined: 16 Sep 2008 00:13
Location: Texas


Return to Modding Techniques

Who is online

Users browsing this forum: No registered users and 3 guests