23:13:58 16 April 2014 |
|
SacriPan
Senior Resident
 On forum: 09/20/2009
 Message edited by: SacriPan 04/16/2014 23:26:43
Messages: 319
|
Assigning a Smart Terrain to a NPC spawned by script
Hi Stalkers,
Is it possible to tie a NPC spawned by script to a Smart Terrain?
I know it can be done via the all.spawn section of an NPC but I have to spawn the NPC/mutants by script only.
I also don't want to use the game respawner (spawn_sections.ltx), I will exclusively use a script to spawn NPCs/mutants.
Is it possible and if so, how?
Thanks |
11:11:18 17 April 2014 |
|
SacriPan
Senior Resident
 On forum: 09/20/2009
 Message edited by: SacriPan 04/17/2014 11:22:15
Messages: 319
|
Wow, thanks a lot TKGP!
I knew about the packet_utils because I read some threads about it here and there but I never used it myself (I didn't know what it was exactly).
It seems "easy" enough to use and very handy for what I wanna do.
Also, yesterday I tried to set up a Smart Terain in cordon (on the road just over the underpass, near the rookie village), by following Dez tutorial on the wiki (or Lost Alpha ModDB page)
I defined the ST in the all.spawn with a condition:
cond = {+my_info_portion} ;; the info_portion is defined in info_portions.xml
The "+" sign means that the actor must have the info_portion so the ST can be active, right?
So, if I had set it to "-", it would mean that the actor can't have the info_portion in order to activate the ST, am I correct?
In gulag_escape.ltx:
- I set up 2 jobs for my ST (kamp, state{0} only)
In gulag_escape.script
- I load the jobs and add a predicate to them (I only want Stalkers/rookies to use them)
t.predicate = function(obj_info) return obj_info.community = "stalker" end
- I load the states for the jobs
- I check the community in the appropriate function
I think I set it up right, but the thing is that when I start a new game, all hell breaks loose.
Or more accurately, all ST are acting weird: the rookies, the soldiers, even the 2 boars at the edge of the rookie camp seems to have no ST assigned anymore. They just walk around in the level.
I would understand that rookies and Wolf would go to my ST (they don't...) because of their "stalker" community, but military and mutants? Why are they moving out of their ST as well (why aren't they taking the available jobs)?
Please note that technically, I didn't assigned any NPC to my ST yet, but that can't be the reason as in the vanilla game, a lot of STs are empty or not full.
I used the debug tool from Dez and a lot of the default STs and mine are never active (despite that I assigned a main menu key to trigger a script that gives/removes the info_portions to activate/deactivate my ST)
I followed the tutorial and I think I got it right. Obviousely, I'm wrong...
What am I missing here?
Question:
Why should I use a predicate in the load_job() function when I also have to bind NPCs/mutants to my ST with their logic config? It seems redundant.
Thanks |
14:01:13 17 April 2014 |
|
SacriPan
Senior Resident
 On forum: 09/20/2009
Messages: 319
|
Thanks Vintar.
I'll check the script when I get back from work.
On a side note, A-Life randomly walking around in the cordon is a funny thing to witness, and it opens our eyes on how a well tuned A-life could be more immersive and entertaining for the player |
14:19:02 17 April 2014 |
|
SacriPan
Senior Resident
 On forum: 09/20/2009
Messages: 319
|
An other question related to spawn/respawn.
Can I spawn a NPC by script and tie it to a Smart Terrain without having any respawn done by the game?
I don't want the game respawner to populate the map, I will do it myself via a script (to control exactly who/what is on the map AND WHEN).
The thing is that to spawn a NPC via script, I have to define its section in "gamedata/creatures/respawn_section.ltx".
Does this section in this particular file means that if this NPC is tied to a Smart Terrain and eventually dies, the game will respawn a similar NPC to occupy my Smart Terrain automatically after a certain time? |
14:26:47 17 April 2014 |
|
oddFlow
(Novice) On forum: 04/12/2014
 Message edited by: oddFlow 04/17/2014 14:33:41
Messages: 15
|
I'm pretty sure if you don't add respawner sections in the map, nothing will respawn. That's why some NPC's can travel through the maps.
For example certain respawner on dark valley is ready to spawn some loners, and every loner on some cordon camp died, and it's smart terrain is now available. Now those stalkers will spawn there, and come to cordon to occupy it (mostly in offline, unless you spot them doing that).
That's why you notice some npc's/mutants coming from behind the level changers into the levels. Isn't that right?
So if you're respawning them by script, I don't think you should worry about normal respawners, as long as there are none. |
15:13:19 17 April 2014 |
|
SacriPan
Senior Resident
 On forum: 09/20/2009
Messages: 319
|
Thanks guys.
#oddFlow
---QUOTATION--- So if you're respawning them by script, I don't think you should worry about normal respawners, as long as there are none. ---END QUOTATION---
But how can I spawn a NPC via a script if I don't add its custom section to the "spawn_sections.ltx" file?
And if I add it, isn't this what will eventually trigger a "normal respawn"?
#Vintar
---QUOTATION--- Your specific npc won't be respawned unless defined in one of the respawners custom data. ---END QUOTATION---
I believe I need a specific section to be defined in the "spawn_sections.ltx" file to spawn my NPC, otherwise the "alife:create()" function won't find my NPC. No?
To sum it up:
How can I spawn a NPC via script without ever having to worry about the game respawning him at all? |
17:39:20 17 April 2014 |
|
oddFlow
(Novice) On forum: 04/12/2014
 Message edited by: oddFlow 04/17/2014 17:40:29
Messages: 15
|
I told you, if you don't add a respawner section, he won't respawn. Look, this is how it looks in all.spawn:
[345]
; cse_abstract properties
section_name = respawn
name = esc2_respawn_bandits_fabrika
position = 301.152526855469,16.7477245330811,24.7992668151855
direction = 0,0,-1.07722399889099e-007
; cse_alife_object properties
game_vertex_id = 139
distance = 19.6000003814697
level_vertex_id = 565014
object_flags = 0xffffff3e
custom_data = <<END
[respawn]
respawn_section = esc_bandit_respawn_2,12, esc_bandit_respawn_1,9
;max_count = 8
;min_count = 1
max_spawn = 6
idle_spawn = medium
;conditions = {+esc_kill_bandits_quest_kill} 80, 0
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
//////////////////////////////////////////////
See, it's not part of smart terrain at all, it's section_name = respawn, a different kind of section. So if you don't add any of these, you really don't have to worry about respawning. So you can include your NPC in any file you want, as long as you don't add him in in one of these sections, he won't respawn this way, and you can make him respawn just by your script. |
|