ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Assigning a Smart Terrain to a NPC spawned by script

1 2 3 4 5 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  23:13:58  16 April 2014
profilee-mailreply Message URLTo the Top
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
  01:38:31  17 April 2014
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
Messages: 454
The excellent packet_utils allows you to set custom_data from script (among many other things). For example,

local data = packet_utils.get_object_data( sObj ) --where sObj is a server object reference to your NPC
data.custom_data = "[smart_terrains]\nesc_lager = true"
packet_utils.set_object_data( sObj, data )

  11:11:18  17 April 2014
profilee-mailreply Message URLTo the Top
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
  13:45:35  17 April 2014
profilee-mailreply Message URLTo the Top
Vintar
a bit of this and a lot of that
(Resident)

 

 
On forum: 08/08/2008
Messages: 6349

---QUOTATION---
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.
---END QUOTATION---



I would assume to make them exclusive so they don't get kicked out of the ST. About your problem, sounds like you made a typo in the gulag script.
  14:01:13  17 April 2014
profilee-mailreply Message URLTo the Top
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
profilee-mailreply Message URLTo the Top
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
profilee-mailreply Message URLTo the Top
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.
  14:54:26  17 April 2014
profilee-mailreply Message URLTo the Top
Vintar
a bit of this and a lot of that
(Resident)

 

 
On forum: 08/08/2008
Messages: 6349
Respawns already on the map can possibly occupy your smart terrain, assuming the npcs they are respawning meets the predicate requirement. Your specific npc won't be respawned unless defined in one of the respawners custom data.
  15:13:19  17 April 2014
profilee-mailreply Message URLTo the Top
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
profilee-mailreply Message URLTo the Top
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.
 
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.