-- Pokaże jak tabela ma wyglądać na przykładzie artefaktów.
local artefacts_table = {
["af_medusa"] = {1, 0.25},
["af_cristall_flower"] = {1, 0.25}
}
-- Oddzielna tabela dla amunicji
local ammo_table = {
["ammo_9x18_fmj"] = {1, 0.25}
}
function main()
for index_id = 1, 65535 do
local npc = level.object_by_id(index_id)
if npc ~= nil and
npc:alive() and
npc:name() ~= db.actor:name() and
npc:character_community() ~= "trader" and
IsStalker(npc)
then
spawn_random_equipment(npc)
end
end
end
function spawn_random_equipment(npc)
-- Spawn losowych artefaktów
for k, v in pairs(artefacts_table) do
for index = 1, v[1] do
if math.random() > v[2] then
spawn_item_in_inv(k, npc)
break
end
end
end
-- Spawn losowej amunicji
for k, v in pairs(ammo_table) do
for index = 1, v[1] do
if math.random() > v[2] then
spawn_ammo_in_inv(k, npc)
break
end
end
end
end
-- Funkcja spawnująca przedmiot w ekwipunku NPC
function spawn_item_in_inv(item, npc)
alife():create(item, npc:position(), npc:level_vertex_id(), npc:game_vertex_id(), npc:id())
end
-- Funkcja spawnująca amunicję w ekwipunku NPC
function spawn_ammo_in_inv(item, npc)
local box_size = system_ini():r_u32(item, "box_size")
se_respawn.create_ammo(item, npc:position(), npc:m_level_vertex_id(), npc:m_game_vertex_id(), npc:id(), box_size)
end