add game&rawdata
This commit is contained in:
parent
0133cd976c
commit
49b34b5546
45731 changed files with 709831 additions and 0 deletions
139
gamedata/scripts/sr_light.script
Normal file
139
gamedata/scripts/sr_light.script
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
local light_zones = {}
|
||||
|
||||
local indoor_levels = {
|
||||
jupiter_underground = true
|
||||
}
|
||||
---------------------------------------------------------------------------------------------------------------------
|
||||
class "action_light"
|
||||
function action_light:__init (obj, storage)
|
||||
self.object = obj
|
||||
self.st = storage
|
||||
self.active = false
|
||||
self.id = obj:id()
|
||||
end
|
||||
function action_light:reset_scheme()
|
||||
printf("Light zone insert")
|
||||
light_zones[self.id] = self
|
||||
end
|
||||
function action_light:update(delta)
|
||||
if xr_logic.try_switch_to_another_section(self.object, self.st, db.actor) then
|
||||
self.active = false
|
||||
self.stalkers = {}
|
||||
printf("Light zone set nil")
|
||||
light_zones[self.id] = nil
|
||||
return
|
||||
end
|
||||
self.active = true
|
||||
end
|
||||
function action_light:check_stalker(stalker)
|
||||
if self.active == false then
|
||||
return false, false
|
||||
end
|
||||
|
||||
if self.object:inside(stalker:position()) then
|
||||
return self.st.light, true
|
||||
end
|
||||
|
||||
return false, false
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------------------
|
||||
function add_to_binder(npc, ini, scheme, section, storage)
|
||||
--' printf("DEBUG: add_to_binder: scheme='%s', section='%s'", scheme, section)
|
||||
local new_action = action_light (npc, storage)
|
||||
xr_logic.subscribe_action_for_events(npc, storage, new_action)
|
||||
end
|
||||
|
||||
function set_scheme(npc, ini, scheme, section, gulag_name)
|
||||
local st = xr_logic.assign_storage_and_bind(npc, ini, scheme, section)
|
||||
st.logic = xr_logic.cfg_get_switch_conditions(ini, section, npc)
|
||||
st.light = utils.cfg_get_bool (ini, section, "light_on", npc, false, false)
|
||||
end
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------------------------------
|
||||
function check_light(stalker)
|
||||
--' printf("[check_light %s] start", stalker:name())
|
||||
if stalker == nil then
|
||||
return
|
||||
end
|
||||
|
||||
--' printf("[check_light %s] start_passed", stalker:name())
|
||||
local torch = stalker:object("device_torch")
|
||||
if torch == nil then
|
||||
return
|
||||
end
|
||||
|
||||
--' printf("[check_light %s] torch_passed", stalker:name())
|
||||
local light = false
|
||||
local forced = false
|
||||
|
||||
if benchmark.light then
|
||||
light = true
|
||||
forced = true
|
||||
end
|
||||
|
||||
if stalker:alive() == false then
|
||||
light = false
|
||||
forced = true
|
||||
end
|
||||
|
||||
--' printf("[check_light %s] alive_passed: light=%s, forced=%s", stalker:name(), tostring(light), tostring(forced))
|
||||
--' Ïðîâåðêà ïî ëàéòçîíàì
|
||||
if not forced then
|
||||
for k,v in pairs(light_zones) do
|
||||
light, forced = v:check_stalker(stalker)
|
||||
if forced == true then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--' printf("[check_light %s] lightzone_passed: light=%s, forced=%s", stalker:name(), tostring(light), tostring(forced))
|
||||
if not forced then
|
||||
--' Ïðîâåðêà ïî âðåìåíè ñóòîê (íî÷üþ âñåãäà âêëþ÷åíî)
|
||||
local htime = level.get_time_hours()
|
||||
if htime <= 4 or htime >= 22 then
|
||||
light = true
|
||||
end
|
||||
|
||||
--' Ïðîâåðêà íà èíäîð-àóòäîð (âíóòðè âñåãäà âêëþ÷åíî)
|
||||
if light == false then
|
||||
if indoor_levels[level.name()] == true then
|
||||
light = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--' printf("[check_light %s] timezone_passed: light=%s, forced=%s", stalker:name(), tostring(light), tostring(forced))
|
||||
--' Ïðîâåðêà ïî àêòèâíîìó äåéñòâèþ
|
||||
if not forced and light == true then
|
||||
--' Ôîíàðèêè äîëæíû áûòü âûêëþ÷åíû ó êîñòðà
|
||||
local scheme = db.storage[stalker:id()].active_scheme
|
||||
if scheme == "kamp" or
|
||||
scheme == "camper" or
|
||||
scheme == "sleeper"
|
||||
then
|
||||
light = false
|
||||
forced = true
|
||||
end
|
||||
end
|
||||
|
||||
--' printf("[check_light %s] scheme_passed: light=%s, forced=%s", stalker:name(), tostring(light), tostring(forced))
|
||||
if not forced and light == true then
|
||||
--' Ôîíàðèêè äîëæíû áûòü âûêëþ÷åíû â áîþ. Íî åñëè â áîþ èäåò ïîèñê âðàãà - òî âêëþ÷åíû.
|
||||
if stalker:best_enemy() ~= nil and indoor_levels[level.name()] ~= true then
|
||||
light = false
|
||||
end
|
||||
end
|
||||
|
||||
if light ~= nil then
|
||||
torch:enable_attachable_item(light)
|
||||
end
|
||||
end
|
||||
|
||||
function clean_up ()
|
||||
--' printf("Light zones cleanup")
|
||||
light_zones = {}
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue