 |
 |
 |
|
 |
 |
 |
|
 |
 |
spawning through a script help |
|
1 2 3 | Next 10 events »| All Messages |
|
|
16:51:33 20 February 2013 |
|
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 |
|
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. 
My Computer Profile: http://www.sysprofile.de/id85555
|
21:31:21 20 February 2013 |
|
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 |
05:27:14 25 February 2013 |
|
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 |
20:09:28 25 February 2013 |
|
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.
"Between you and us, that thing that killed you is a total dick. Please disregard this message if you committed suicide."
http://www.moddb.com/members/insanelazarez/videos/stalker-mutant-zone-tribute#imagebox
http://moddercove.blogspot.com/2011/05/x-ray-engine-e-ia-quello-che-non.html
Diary of a modder:
http://s693.photobucket.com/albums/vv297/insanelazarez/Diary%20of%20a%20Modder/
So, i dare to assume your time machine is better than my time machine, huh? Stupid dog.
Ahh, my old youtube account, check this one out:
http://www.youtube.com/watch?v=1Fu2oyn1Eps
|
|
1 2 3 | Next 10 events »| All Messages |
|
|
|
» » |
|
All short dates are in Month-Day-Year format. |
 |
|
 |
|
|
|
 |
 |
 |