Divergent/mods/Usable Bar Doors/gamedata/scripts/kpop_doors.script

82 lines
2.2 KiB
Plaintext
Raw Permalink Normal View History

2024-03-17 20:18:03 -04:00
local allowed_factions = { ["stalker"] = true, ["csky"] = true, ["dolg"] = true, ["ecolog"] = true, ["army"] = true }
local doors_ar = {
-- bar
{ pos = { 115.53, 1.52, 64.53 }, gvid = 1673, angle = { 0, 1.57, 1.57 } },
{ pos = { 207.43, 2.1, 51.4 }, gvid = 1673, angle = { 1.57, -1.57, 0 } },
{ pos = { 104.28, 1.65, 68.55 }, gvid = 1673, angle = { 1.57, 0, 0 } },
}
local tp_t = {
[32429] = { 32518, 32519, 32427, 32428, 32350, 32351, 32594 },
[32428] = { 32520, 32521, 32429, 32430, 32352, 32353, 32265, 32266 },
[33810] = { 33669, 33811, 34089 },
[33811] = { 33667, 33668, 33809, 33810, 33949, 33950, 34087, 34088 },
[51376] = { 50899, 50900, 50670, 50671 },
[50900] = { 51374, 51375, 51376, 51628, 51629, 51630 },
}
local kpop_doors_placed = false
function actor_on_first_update()
if kpop_doors_placed then return end
for idx, t in ipairs(doors_ar) do
local pos = vector():set(t.pos[1], t.pos[2], t.pos[3])
local lvid = 2^32-1
local gvid = t.gvid
local se_obj = alife_create("the_kpop_door", pos, lvid, gvid)
if se_obj then
se_obj.angle = vector():set(t.angle[1], t.angle[2], t.angle[3])
local data = utils_stpk.get_physic_data(se_obj)
data.custom_data = [[
[collide]
ignore_static
[logic]
cfg = scripts\kpop_door_logic.ltx
]]
utils_stpk.set_physic_data(data, se_obj)
end
end
kpop_doors_placed = true
end
xr_effects.kpop_doors_tp = function(a, b, c)
local lvid = db.actor:level_vertex_id()
for to, from_ar in pairs(tp_t) do
for idx, from in ipairs(from_ar) do
if from == lvid and allowed_factions[get_actor_true_community()] then
local pos = level.vertex_position(to)
db.actor:set_actor_position(pos)
local snd = sound_object("device\\wood_small_open")
if snd then
snd:play_no_feedback(db.actor, sound_object.s2d, 0, VEC_ZERO, 1, 1)
end
return
end
end
end
end
function save_state(m_data)
m_data.kpop_doors_placed = kpop_doors_placed
end
function load_state(m_data)
kpop_doors_placed = m_data.kpop_doors_placed or false
end
function on_game_start()
RegisterScriptCallback("actor_on_first_update", actor_on_first_update)
RegisterScriptCallback("save_state", save_state)
RegisterScriptCallback("load_state", load_state)
end