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

1 2 3 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  16:51:33  20 February 2013
profilee-mailreply Message URLTo the Top
Rattertat
(Novice)
 
On forum: 02/20/2013
Messages: 4
spawning through a script help

Hello stalkers,

I have been checking the forums for some time, but now need a little help with scripting. I have been using the spawning through a script wiki and have been able to spawn using this example script with a function I added matched to a action from selecting a text in the xml during sids first conversation:

Question, it does not say in the Wiki, but what do these #'s mean a,13193,8,65535 ? in this line ("bar_dolg_respawn_3",a,13193,8,65535)

local a = vector() -- Set variable type
a.x = -243.61 -- X coordinate
a.y = -19.52 -- height Y
a.z = -127.17 -- Z coordinate

local obj = alife():create("bar_dolg_respawn_3",a,13193,8,65535)
alife():create_ammo("ammo_9x18_fmj",
obj osition(),
obj:level_vertex_id(),
obj:game_vertex_id(),
obj:id(),
20) -- number of bullets

I have been playing with spawning different NPC’s and so on and it is really cool!

I know want to move onto this script and try to spawn lots of zombies. I do not understand what actually needs to go into the script though there is a lot of info here and the example files go to a dead link.

I want to spawn right outside sids bunker just to see if It works, the coordinates are -240.57, -18.06, -128.62. Will use a function again from a selection text.

Would someone be able to write out for me what the end script should look like from the example? I am confused how it should look in the end and have been trying many combinations, but nuthing works.

Thank you to anyone who can help with questions and explaining.

It says to do this first

local zombie_types = {"zombie_weak", "zombie_normal", "zombie_strong", "zombie_immortal", "zombie_ghost"}

Then this

function spawn_zombies( position, total )
local zombie_index -- zombie type from zombie_types array
local new_pos, x_offset, z_offset -- declare variables
for zombie_index=1, total do -- spin the loop the number of times given by the variable "total"
x_offset = math.random(5) -- random x between 1 and 5
z_offset = math.random(5) -- random z between 1 and 5
new_pos = position -- transfer the coordinates to a function
new_pos.x = new_pos.x + x_offset -- add the random x to the x coordinate
new_pos.z = new_pos.z + z_offset -- add the random z to the z coordinate
-- below we call the function of random zombie spawn itself for zombie_types[math.random(5)] tied to our coordinates
alife():create(zombie_types[math.random(5)], new_pos, db.actor:level_vertex_id(), db.actor:game_vertex_id())
end
end

This is last

function zomby_story_1( actor, npc )
-- ten zombies at the plant
local spawn_point = vector():set( 115, -6, -16 ) -- here we specify the coordinates we got while "flying"
spawn_zombies( spawn_point, 10 ) -- here is the call of the previous function itself, giving it the coordinates and the number of objects
end
  19:53:49  20 February 2013
profilee-mailreply Message URLTo the Top
ThunderFreak
Senior Resident
 

 
On forum: 08/07/2009
 

Message edited by:
ThunderFreak
02/20/2013 19:54:56
Messages: 685
Check this out. It works.

local zombie_types = {"zombie_weak", "zombie_normal", "zombie_strong", "zombie_immortal", "zombie_ghost"}
local zombie_IDs = {}
function spawn_zombies()
	local zombie_nr = #zombie_IDs or 0		-- Check if some zombies still "alive"
	if zombie_nr > 0 then
		local z_obj
		for i=1,zombie_nr do
			obj = level.object_by_id(zombie_IDs[i])	-- Check which zombies are relally dead :-D
			if obj == nil then
				zombie_IDs[i] = nil		-- Delete array entry
			end
		end
		return							-- Return as long as zombies alive
	end
	
	-- Spawn new zombies if all other zombies are gone
	local new_pos = vector():set(-240.57, -18.06, -128.62)
	local lvid = db.actor:level_vertex_id()
	local gvid = db.actor:game_vertex_id()
	local spid
	for i=1,10 do
		new_pos.x = new_pos.x + math.random(5)
		new_pos.z = new_pos.z + math.random(5)
		spid = alife():create(zombie_types[math.random(4)], new_pos, lvid, gvid)
		zombie_IDs[i] = spid.id
	end
end


Zombies are spawned in front of sidos bunker. I extended your script a little bit. Checking if zombies are alive and if not spawn again.

Keep the rookies busy.
  21:31:21  20 February 2013
profilee-mailreply Message URLTo the Top
Rattertat
(Novice)
 
On forum: 02/20/2013
 

Message edited by:
Rattertat
02/21/2013 6:14:30
Messages: 4
Wow! Thank you so much, it works!! Very awesome!!

A couple questions if you dont mind Thunderfreak.

Can I use this as a template to spawn other monsters using different coordintaes and function command linked to an action in XML?

1 other thing, I have added back monster parts and set prob. to .4 for zombie hand, but all zombies that are spawned have in their inventory, do you know why that is?

Thank you so much again
  13:46:25  21 February 2013
profilee-mailreply Message URLTo the Top
ThunderFreak
Senior Resident
 

 
On forum: 08/07/2009
Messages: 685
I have a better idea. Check out my skydrive, there is a mini mod called Ueberfaelle. You can use this one, if you like.

https://skydrive.live.com/#cid=839FA75832089767&id=839FA75832089767!268

This mini mod starts military raids in the zone. There are 2 spawn points in each level. You can replace the soldiers with what you like i.e. bandits, monsters and so on or a combination of all.
  20:40:06  21 February 2013
profilee-mailreply Message URLTo the Top
insanelazarez
Yeah, Good Luck With That...
(Resident)

 

 
On forum: 01/31/2009
Messages: 1070

---QUOTATION---
Ueberfaelle
---END QUOTATION---



Ok, ThunferFreak... about your 'Ueberfaelle', you have a spawn section with the name 'pri_respawn_military'. This section has 'custom_logic' for pripyat. Spawning them in other maps... the game will break. It's a matter of time.


You should replace them... by other soldiers.

Just saying...
  20:43:34  21 February 2013
profilee-mailreply Message URLTo the Top
ThunderFreak
Senior Resident
 

 
On forum: 08/07/2009
 

Message edited by:
ThunderFreak
02/21/2013 21:43:01
Messages: 685
Thanks, Insanelazarez. I'll take a look.

EDIT: You're right. Kick them out.
  05:27:14  25 February 2013
profilee-mailreply Message URLTo the Top
Rattertat
(Novice)
 
On forum: 02/20/2013
Messages: 4
Hi Thunder, thank you very much for writting the script out again. I have been testing it alot and am not sure if a bug. I sometimes get 1 zombie or maybe 10, sometimes I also get 0. It is very random, how do I set an exact number, like 10 or 5, etc... I have tried changing some variables in
the script, but either nothing happens or I crash...

Thank you for the link to your other scripts/mods, but I need to take baby steps and want to learn from the one you posted before I start going crazy
  17:12:07  25 February 2013
profilee-mailreply Message URLTo the Top
ThunderFreak
Senior Resident
 

 
On forum: 08/07/2009
Messages: 685
Did you change something on the script example I posted?

The number of spawns cannot be random. The spawn amount is set to 10.

for i=1,10 do

Add a "debug" line after the line
zombie_IDs[i] = spid.id

to see how many zombies are really spawned.
The debug line is
dbglog("ID %s is spawn number %s",tostring(zombie_IDs[i]),tostring(i))


When you finish the game then you will see in the game log file how many zombies has been spawned on each spawn action.
Hope that helps.
  20:09:28  25 February 2013
profilee-mailreply Message URLTo the Top
insanelazarez
Yeah, Good Luck With That...
(Resident)

 

 
On forum: 01/31/2009
 

Message edited by:
insanelazarez
02/25/2013 20:10:47
Messages: 1070

---QUOTATION---
Did you change something on the script example I posted?

The number of spawns cannot be random. The spawn amount is set to 10.

for i=1,10 do

Add a "debug" line after the line
zombie_IDs[i] = spid.id

to see how many zombies are really spawned.
The debug line is
dbglog("ID %s is spawn number %s",tostring(zombie_IDs[i]),tostring(i))


When you finish the game then you will see in the game log file how many zombies has been spawned on each spawn action.
Hope that helps.
---END QUOTATION---



Well, he is creating items by script... so he might see 7 zombies only... and in the next test... kazaam 9 zombies. And this without considering how fast or slow his system is. It's important see... cause the script never produces the spawn in the same place. Sometimes you want a zombie to spawn 100 metters from you, but... no, he is spawning 3 metters from you. That is 97 metters from the position you want him to spawn. That's one of the reasons why i only add creatures by all.spawn. But i use new functions too, of course i do. In special new functions to allow npcs to create... some item close of their position... but the spawn of the creature itself... must be added by all.spawn. It's the only accurate way to spawn a creature... in position x,y,z. The position will always be the same.
  22:09:09  25 February 2013
profilee-mailreply Message URLTo the Top
ThunderFreak
Senior Resident
 

 
On forum: 08/07/2009
Messages: 685
Almost all my spawns I do with script spawn. Never had the problem you described. The items, monsters, zombies and so on always appeared at the spawn coordinates.
And in his script the difference to the spawn point is max. 5 meters.
 
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-2020 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.