olaf1
Senior Resident
On forum: 01/17/2012
 Message edited by: olaf1 03/24/2012 15:18:41
Messages: 240
|
Npc by script respawnen
hey gus i have make a script for respwan npc´s
could someone tell me what I should improve or do differently such that would be really nice
It is not yet finished and therefore also a prototype
local npc_table = {
"mar_clear_sky_respawn_1",
"mar_clear_sky_respawn_2",
"mar_clear_sky_respawn_3",
}
local table = {}
local koordianten = {}
local respwan_tabel = {}
local timer = nil
local levels = {marsh= {x=-61.996055603027,y=0.92057931423187,z=293.67742919922},
l01_escape= {x=-61.996055603027,y=0.92057931423187,z=293.67742919922},
l02_garbage= {x=-61.996055603027,y=0.92057931423187,z=293.67742919922},
l03_agroprom= {x=-61.996055603027,y=0.92057931423187,z=293.67742919922},
l04_darkvalley= {x=-61.996055603027,y=0.92057931423187,z=293.67742919922},
l05_bar= {x=-61.996055603027,y=0.92057931423187,z=293.67742919922},
l06_rostok= {x=-61.996055603027,y=0.92057931423187,z=293.67742919922},
l07_military= {x=-61.996055603027,y=0.92057931423187,z=293.67742919922},
l08_yantar= {x=-61.996055603027,y=0.92057931423187,z=293.67742919922}
calss "Respwan_NPC"
function Respwan_NPC:LoadInfos()
if db.actor:alive() == false then return end
npc_name = npc_table[math.random(1, 3)]
table[npc_name] = false
for lvl, pos in pairs(levels) do
if level_name == lvl then
if lvl == "marsh" then
local pos = vector():set(pos.x, pos.y, pos.z)
local lvi = db.actor:level_vertex_id()
local gvi = db.actor:game_vertex_id()
local koordianten = pos,lvi,gvi
end
end
end
if npc_name == false then
self:Timer(npc_name,koordianten)
end
end
function Respwan_NPC:Timer(npc_name,pos)
if db.actor:alive() == false then return end
local level_name = level.name()
if spwan == false then
if timer == nil then
timer = level.get_time_hours() + math.random(3, 6)
if timer > 23 then timer = timer - 24 end
end
if time_global() > timer then
timer = nil
self:Spwan(npc_name,pos)
end
end
end
function Respwan_NPC:Timer(npc_name,pos)
for k,v in pairs(table)do
if v == false then
respwan_tabel[alife():create(k,pos).id] = true
table[npc_name] = true
end
end
self:Check_NPC_Dead(npc_name)
end
function Respwan_NPC:Check_NPC_Dead(npc)
if npc and npc:alive() == false then
table[npc] = false
end
end
i hope that anyoen help me.
This script can of course be some errors drinne it would be very nice if you could make me aware of this. |