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

1 2 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  18:07:58  12 March 2012
profilee-mailreply Message URLTo the Top
olaf1
Senior Resident
 

 
On forum: 01/17/2012
 

Message edited by:
olaf1
03/12/2012 18:21:15
Messages: 240
Spwan script

Hey guys

i hvae a long time not work with modding

and yet i don´t know what i have to do yet.

i will make a script with i can spwan NPC´s



function spwawn()

local spwan_point = {-61.996055603027, 0.92057931423187, 293.67742919922,3402,106182}

alife():create("mar_clear_sky_respawn_1", vector():set(spwan_point))

alife():create("mar_clear_sky_respawn_2", vector():set(spwan_point))

alife():create("mar_clear_sky_respawn_3", vector():set(spwan_point))

end



but when i hvae inculd it in the bin_stalker.script


npc_spawnen2.spwawn()



then the npc´s don´t spwan

why?

can i spwan it only with a dialog and then with <action>?

thanke you.
  20:48:36  12 March 2012
profilee-mailreply Message URLTo the Top
Vintar
a bit of this and a lot of that
(Resident)

 

 
On forum: 08/08/2008
Messages: 6349
I would imagine you need to add graph and level id for them to spawn accurately. What i mean is that they may well be spawning but possibly on another level, who knows.
  17:47:57  13 March 2012
profilee-mailreply Message URLTo the Top
olaf1
Senior Resident
 

 
On forum: 01/17/2012
 

Message edited by:
olaf1
03/13/2012 17:52:07
Messages: 240
can anyone say me can this works??


local respwan_table = {}
local timer = 0
local timer_repswan = 0
local spwan = false
function spwawn()
local levels = [{0] = "marsh", [1] = "l01_escape", [2] = "l02_garbage", [3] = "l03_agroprom", [4] = "l04_darkvalley", [5] = "l05_bar", [6] = "l06_rostok", [7] = "l07_military", [8] = "l08_yantar"}
local level_name = level.name()
if spwan == false then
	if timer == 0 then timer = time_global() + math.random(36, 60) end

		if db.actor:alive() then

			if time_global() > timer then

			timer = 0 
				for indx, lvl in pairs(levels) do

					if level_name == lvl then

					ws = indx
					spwan = true	        
						if spwan == true then
								if ws == 0 then
								spwan = 
								alife():create("mar_clear_sky_respawn_1", vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
								alife():create("mar_clear_sky_respawn_2", vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
								alife():create("mar_clear_sky_respawn_3", vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
								respwan_table[spwan.id] = true
								end
						end
					end
				end
			end
		end
	end
if type(respwan_table) == "table" then
local obj,count,tbl_cnt = nil,0,#respwan_table 

for k,v in pairs(respwan_table) do
obj = alife():object(k)

if obj == nil then
v = nil   
if timer_repswan == 0 then timer = time_global() + math.random(36, 60) end

	if db.actor:alive() then

		if time_global() > timer_repswan then

			timer_repswan = 0  
			alife():create(v, vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
		end
	end
end
end
end
end





thank you

i don´t can test it in this time
i hope anyoen can make it for me.
  19:00:38  13 March 2012
profilee-mailreply Message URLTo the Top
olaf1
Senior Resident
 

 
On forum: 01/17/2012
 

Message edited by:
olaf1
03/13/2012 20:48:11
Messages: 240
oh sorry

i have a completer script


local first_spwan = false
local respwan_table = {}
local timer = 0
local timer_repswan = 0
local spwan = false

function spwawn()
local levels = [{0] = "marsh", [1] = "l01_escape", [2] = "l02_garbage", [3] = "l03_agroprom", [4] = "l04_darkvalley", [5] = "l05_bar", [6] = "l06_rostok", [7] = "l07_military", [8] = "l08_yantar"}
local level_name = level.name()
if spwan == false then
	if timer == 0 then timer = time_global() + math.random(36, 60) end

		if db.actor:alive() then

			if time_global() > timer then

			timer = 0 
				for indx, lvl in pairs(levels)do
					if level_name == lvl then
					ws = indx
					spwan = true	        
						if spwan == true then
								if ws == 0 then
								spawn = 
								alife():create("mar_clear_sky_respawn_1", vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
								alife():create("mar_clear_sky_respawn_2", vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
								alife():create("mar_clear_sky_respawn_3", vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
								respwan_table[spawn.id] = true
								first_spwan = true
								end
						end
					end
				end
			end
		end
	end	
if first_spwan == true then
if type(respwan_table) == "table" then
local obj,count,tbl_cnt = nil,0,#respwan_table 

for k,v in pairs(respwan_table) do
obj = alife():object(k)

if obj == nil then
k = respwan_npc_name
v = nil   
if timer_repswan == 0 then timer = time_global() + math.random(36, 60) end
	if db.actor:alive() then
		if time_global() > timer_repswan then
			timer_repswan = 0  
			spawn = alife():create(respwan_npc_name, vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
			respwan_table[spawn.id] = true
		end
	end
end
end
end
end
end



but when i kill a npc the npc don´t respwan but why?

can anyoen help me?

thank you
  21:21:29  13 March 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
 

Message edited by:
SetaKat
03/13/2012 21:22:33
Messages: 6340
I hate to say it, but that script is an absolute mess. Even I don't know where to begin debugging it. The reason it probably isn't excuting is that it isn't even valid syntax (I've spotted several errors already)

If just respawning an npc is all you want to do, just spawn them through an ltx config. Its easier, and you don't have to mess around with keeping track of variables in scripts. And it is a lot shorter, and easier to manage.
From my mod (for CS, but most likely compatible with SoC)

[logic]
active = sr_idle@check

[sr_idle@check]
on_info = {!counter_greater(gar_walker_count:8) =dist_to_actor_ge(100)} sr_idle@spawn_walker

[sr_idle@spawn_walker]
on_game_timer = 2000 | sr_idle@check %=inc_counter(gar_walker_count) =spawn_object(sim_gar_stalker_default_walker_1:gar_stalker_walker_spawn)%


All this does is every 2000 ingame seconds, it checks to see if we can spawn a special npc. If we can, spawn them at some way point. The NPC has their own logic, and just excutes that. This sample is set up to spawn 8 npc's, but could easily be adjusted to spawn any number.
Its easier to read and understand, we don't have to manage time checks, spawning of npc's, checking to see if they are dead - the game does that for us.
And the npc logic (just the basic parts)

[logic]
active = mob_home@base
on_death = death
on_hit = hit

;roam sequence
[mob_home@base]
path_home = gar_walker_home
home_min_radius = 10
home_max_radius = 40

;death and hit info
[death]
on_info = %=dec_counter(gar_walker_count)%

[hit]
on_info = {=npc_not_hit_by_actor} nil %=npc_hit_npc%


All this does is define what they will do as their job, when they get hit, and when they die.
You'll want your logic to be pointing to your npc's own custom job, or sending them to a smart terrain.

If you still want to do thsi via script, I strongly suggest using this tool to check your scripts before trying them ingame: https://www.gsc-game.com/index.php?t=community&s=forums&s_game_type=xr&thm_page=88&thm_id=15106&sec_id=16
It will help find any syntax errors in your script that will prevent it working ingame. The seconds needed to run this could save hours ingame, trying to debug your script.
  22:52:31  13 March 2012
profilee-mailreply Message URLTo the Top
olaf1
Senior Resident
 

 
On forum: 01/17/2012
Messages: 240
thanke you but i will that when the npc is dead
not when the actor kill him
  02:43:57  14 March 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6340
The good thing about the code I listed is that it works even if the actor doesn't even shoot a Stalker. I can used this code to create an infinite number of respawning Stalkers and Bandits in garbage, and just have them killing each other. When 1 dies, a new one gets spawned after some delay.

When my npc dies, a counter gets reduced (gar_walker_count) from their logic. In my spawn logic config, if that counter is less than 8, spawn a new npc. It doesn't matter how they die - actor, another npc, mutant, anomaly, or even death via script - the counter gets reduced, and a new npc spawned to take his place.

The game provides all of these functions in xr_conditions and xr_effects to use in logic ltx files, so you don't need to reinvent the wheel to spawn an npc - its all there. You just need to combine it into a config.

Besides, with this approach, link the spawner ltx config to a space restrictor on the marsh level, and it will only run on the marsh level. Your script will run on all levels, and just waste cpu cycles evaluating various if statements.
Now, this section of your code here:

local levels = [{0] = "marsh", [1] = "l01_escape", [2] = "l02_garbage", [3] = "l03_agroprom", [4] = "l04_darkvalley", [5] = "l05_bar", [6] = "l06_rostok", [7] = "l07_military", [8] = "l08_yantar"}
local level_name = level.name()
... stuff here
for indx, lvl in pairs(levels)do
	if level_name == lvl then
		ws = indx
		spwan = true	        
		if spwan == true then
			if ws == 0 then
				... stuff here
			end
		end
	end
end


Is a huge waste of resources. It would be better written as this:

local level_name = level.name()
... stuff here
if level_name == "marsh" then
	... stuff here
end


Your script has a lot of redunant code. You only need to spawn on marsh, so there is no need to loop though a table of level names, and check them against the current level name, so we can get rid of that. And then the level number in the table, which you check, even after checking that we have the right number is redundant, so that can go. And setting some variable to true, then checking to make sure it is true? redundant, so that can go.
So, assuming that these are our scripts, yours would do about 7 different steps before even getting to the spawn code, not to mention it wil run over all the variables in your level list, whereas my tidied code does it in 2, and are functionally identical. Mine is faster, easier to read, and debug.

The reasons your script probably isn't workng is numerous syntax errors. I've spotted 2 that would stop it working, and I haven't even used the LUA checker yet, and that might turn up even more. When writing scripts, that lua checker I linked is your best friend. And there are several more that would pass the checker, but fail ingame and cause a ctd because they are the wrong types for what you are trying to use them for (eg your trying to use a int where a string is expected in one section)
Also, no where in this code, is a check to see if one of your npc's is dead, so even if this script was working, it would just spam spawn npc's every time the timer expired.

I would like to help you fix this, but it is simply a mess. It would be 100 times easier to just use ltx configs.

Create a space restrictor on the marsh level, assign it a type of 4, link an ltx config, and put this inside the config

[logic]
active = sr_idle@check

[sr_idle@check]
on_info = {-mar_csky_stalker_1) =dist_to_actor_ge(100)} sr_idle@spawn_csky_stalker_1
on_info2 = {-mar_csky_stalker_2) =dist_to_actor_ge(100)} sr_idle@spawn_csky_stalker_1
on_info3 = {-mar_csky_stalker_3) =dist_to_actor_ge(100)} sr_idle@spawn_csky_stalker_1

[sr_idle@spawn_csky_stalker_1]
on_game_timer = 2000 | sr_idle@check %=+mar_csky_stalker_1 =respawner_spawn(mar_clear_sky_respawn_1)%

[sr_idle@spawn_csky_stalker_2]
on_game_timer = 2000 | sr_idle@check %=+mar_csky_stalker_2 =respawner_spawn(mar_clear_sky_respawn_2)%

[sr_idle@spawn_csky_stalker_3]
on_game_timer = 2000 | sr_idle@check %=+mar_csky_stalker_3 =respawner_spawn(mar_clear_sky_respawn_3)%


Remember to recompile the all.spawn
Now just create 3 new infoportions (mar_csky_stalker_1, mar_csky_stalker_2, mar_csky_stalker_3), 3 new logic configs, one for each of your npc profiles that will govern how they will act, what smart terrains they will go to, and they should look like this:

[smart_terrains]
some_marsh_smart_terrain =  true

[logic]
on_death = death

[death]
on_info = %-mar_csky_stalker_x%

and x is the number for the infoportion (1,2,3). Then just link this config with their ltx section.
Done. 3 special respawning npc's on marsh when they die from anything. And if you want to add new npc's, or remove existing ones, then its just recreating a new npc logic file, and adding lines to the spawn script, which are essentially duplicates of the existing ones, or just deleting them.

(some SoC modder may want to double check the npc logic, I just reconstructed it from looking at the files. Should be right, though.)

There is no need to go to this level of trouble, writing a script for such a trival thing, considering GSC left a bunch of functions lying around for this sort of thing, easily formed into a logic config.

If it was a once off spawn, then a custom script function would suffice. But even then, I would call it from a dialog, or an ltx logic config.

Sorry for the block of text.
  09:36:28  14 March 2012
profilee-mailreply Message URLTo the Top
olaf1
Senior Resident
 

 
On forum: 01/17/2012
Messages: 240
can i use this logic script only when i have a smart terrain?

I'm not a smart script that is terrain

because my gulag script don´t works and nobody can me help and say this what i do is right.

must i have a smar terrain?
  15:07:11  14 March 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6340
<facepalm>
Look, I linked a lua script debugger several posts back. Use it!
Here's the first error for you to fix: "line 8: no viable alternative at input '['"

Fix that, run the script though the lua checker repeatedly until you get a "Found 0 errors." message. If it still doesn't work at that stage, then come back and ask for help. No-one here is going to correct the errors in your script for you. You want to write this script, you need to learn the language. And the only way you'll learn is by correcting your mistakes. If thats beyond you to do some simple syntax checking and correcting, I don't care.

And if you really want to reinvent the friggen wheel, be my guest. I'm not going to help you.
  18:32:45  14 March 2012
profilee-mailreply Message URLTo the Top
olaf1
Senior Resident
 

 
On forum: 01/17/2012
 

Message edited by:
olaf1
03/14/2012 19:09:31
Messages: 240
on wich point the npc´s will berespwaned?

on the point of the space restrictor?

and i don´t need a script, is that right?

must i spwan the npc´s first or spwan the logic script this npc´s?

thank you

i hvae test it but the npc´s dont respwan

why?

this is the space restrictor


[42401]
; cse_abstract properties
section_name = space_restrictor
name = mar_lager_1
position = -61.996055603027,0.92057931423187,293.67742919922
direction = -9.74710516743471e-008,0,0

; cse_alife_object properties
game_vertex_id = 3402
distance = 0
level_vertex_id = 106182
object_flags = 0xffffff3e
custom_data = <<END
[logic]
active = sr_idle@check

[sr_idle@check]
on_info = {-mar_csky_stalker_1) =dist_to_actor_ge(100)} sr_idle@spawn_csky_stalker_1
on_info2 = {-mar_csky_stalker_2) =dist_to_actor_ge(100)} sr_idle@spawn_csky_stalker_1
on_info3 = {-mar_csky_stalker_3) =dist_to_actor_ge(100)} sr_idle@spawn_csky_stalker_1

[sr_idle@spawn_csky_stalker_1]
on_game_timer = 2 | sr_idle@check %=+mar_csky_stalker_1 =respawner_spawn(mar_clear_sky_respawn_1)%

[sr_idle@spawn_csky_stalker_2]
on_game_timer = 2 | sr_idle@check %=+mar_csky_stalker_2 =respawner_spawn(mar_clear_sky_respawn_2)%

[sr_idle@spawn_csky_stalker_3]
on_game_timer = 2 | sr_idle@check %=+mar_csky_stalker_3 =respawner_spawn(mar_clear_sky_respawn_3)%

END
story_id = 4444321

; cse_shape properties
shapes = shape0
shape0:type = box
shape0:axis_x = -61.996055603027,0,0
shape0:axis_y = 0,20.92057931423187,0
shape0:axis_z = 0,0,293.67742919922
shape0:offset = 0,0,0

; cse_alife_space_restrictor properties
restrictor_type = 0



and this stand in the logic script of the npc

[smart_terrains]
none = true


[logic]
active = kamp
on_death = death


[kamp]
center_point = mar_clear_sky_general_kamper_001_kamp
meet = meet  
  

[death]
on_info = %-mar_csky_stalker_1%
    
[meet]                     
use = true                
use_wpn = true  



but when the npc is dead he don´t respwan???
 
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.