add game&rawdata
This commit is contained in:
parent
0133cd976c
commit
49b34b5546
45731 changed files with 709831 additions and 0 deletions
145
gamedata/scripts/state_mgr_smartcover.script
Normal file
145
gamedata/scripts/state_mgr_smartcover.script
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
--' Íàõîäèòñÿ ëè óæå ñìàðòêàâåð â íóæíîì ñîñòîÿíèè
|
||||
class "eva_state_mgr_smartcover" (property_evaluator)
|
||||
function eva_state_mgr_smartcover:__init(name, st) super (nil, name)
|
||||
self.st = st
|
||||
end
|
||||
function eva_state_mgr_smartcover:evaluate()
|
||||
if self.st.target_state ~= "smartcover" then
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
local state_descr = db.storage[self.object:id()]["smartcover"]
|
||||
local dest_smart_cover_name = self.object:get_dest_smart_cover_name()
|
||||
|
||||
-- Òàêæå íóæíî äîáàâèòü, ÷òîá ìû íàõîäèìñÿ èìåííî â _íóæíîì_ ñìàðòêàâåðå
|
||||
-- printf("SC %s [%s] [%s]", tostring(dest_smart_cover_name == (state_descr.smartcover_name or "")),
|
||||
-- tostring(dest_smart_cover_name), tostring((state_descr.smartcover_name or "")))
|
||||
if state_descr == nil then
|
||||
return true
|
||||
end
|
||||
return dest_smart_cover_name == (state_descr.cover_name or "")
|
||||
end
|
||||
|
||||
--' Íóæíî ëè íàì âõîäèòü â ñìàðòêàâåð
|
||||
class "eva_state_mgr_smartcover_need" (property_evaluator)
|
||||
function eva_state_mgr_smartcover_need:__init(name, st) super (nil, name)
|
||||
self.st = st
|
||||
end
|
||||
function eva_state_mgr_smartcover_need:evaluate()
|
||||
if self.st.target_state ~= "smartcover" then
|
||||
return false
|
||||
end
|
||||
|
||||
local state_descr = db.storage[self.object:id()]["smartcover"]
|
||||
if state_descr == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
return state_descr.cover_name ~= nil
|
||||
end
|
||||
|
||||
|
||||
--' çàëî÷åíà ëè ñõåìà (íàõîäèìñÿ ëè ìû â ïðîöåññå âõîäà-âûõîäà èç ñìàðòêàâåðà)
|
||||
class "eva_state_mgr_smartcover_locked" (property_evaluator)
|
||||
function eva_state_mgr_smartcover_locked:__init(name, st) super (nil, name)
|
||||
self.st = st
|
||||
end
|
||||
function eva_state_mgr_smartcover_locked:evaluate()
|
||||
local state_descr = db.storage[self.object:id()]["smartcover"]
|
||||
if state_descr == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
local in_smart_cover = self.object:in_smart_cover()
|
||||
|
||||
return (in_smart_cover and state_descr.cover_name == nil) or
|
||||
(not in_smart_cover and state_descr.cover_name ~= nil)
|
||||
end
|
||||
|
||||
|
||||
--' çàëî÷åíà ëè ñõåìà (íàõîäèìñÿ ëè ìû â ïðîöåññå âõîäà-âûõîäà èç ñìàðòêàâåðà)
|
||||
class "eva_state_mgr_in_smartcover" (property_evaluator)
|
||||
function eva_state_mgr_in_smartcover:__init(name, st) super (nil, name)
|
||||
self.st = st
|
||||
end
|
||||
function eva_state_mgr_in_smartcover:evaluate()
|
||||
return self.object:in_smart_cover()
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--' Âõîä â ñìàðòêàâåð
|
||||
class "act_state_mgr_smartcover_enter" (action_base)
|
||||
function act_state_mgr_smartcover_enter:__init(name, st) super (nil, name)
|
||||
self.st = st
|
||||
end
|
||||
function act_state_mgr_smartcover_enter:initialize()
|
||||
action_base.initialize(self)
|
||||
|
||||
--self.move_mgr:finalize()
|
||||
--self.move_mgr = db.storage[npc:id()].move_mgr
|
||||
local state_descr = db.storage[self.object:id()]["smartcover"]
|
||||
printf("setting smartcover [%s] for stalker [%s] ", tostring(state_descr.cover_name), self.object:name())
|
||||
self.object:use_smart_covers_only(true)
|
||||
self.object:set_movement_type(move.run)
|
||||
self.object:set_dest_smart_cover(state_descr.cover_name)
|
||||
|
||||
if state_descr.loophole_name ~= nil then
|
||||
printf("setting smartcover1 [%s] loophole [%s] for stalker [%s] ", tostring(state_descr.cover_name), state_descr.loophole_name, self.object:name())
|
||||
self.object:set_dest_loophole(state_descr.loophole_name)
|
||||
end
|
||||
end
|
||||
function act_state_mgr_smartcover_enter:execute()
|
||||
action_base.execute(self)
|
||||
end
|
||||
function act_state_mgr_smartcover_enter:finalize()
|
||||
action_base.finalize(self)
|
||||
end
|
||||
|
||||
--' Âûõîä èç ñìàðòêàâåðà
|
||||
class "act_state_mgr_smartcover_exit" (action_base)
|
||||
function act_state_mgr_smartcover_exit:__init(name, st) super (nil, name)
|
||||
self.st = st
|
||||
end
|
||||
function act_state_mgr_smartcover_exit:initialize()
|
||||
action_base.initialize(self)
|
||||
|
||||
local object = self.object
|
||||
object:set_smart_cover_target()
|
||||
object:use_smart_covers_only(false)
|
||||
object:set_smart_cover_target_selector()
|
||||
local vertex = object:level_vertex_id()
|
||||
local npc_position = level.vertex_position(vertex)
|
||||
if not object:accessible(npc_position) then
|
||||
local ttp = vector():set(0,0,0)
|
||||
vertex = object:accessible_nearest(npc_position, ttp)
|
||||
npc_position = level.vertex_position(vertex)
|
||||
printf("accesible position is %s", vec_to_str(npc_position))
|
||||
end
|
||||
object:set_dest_level_vertex_id(vertex)
|
||||
printf("accesible position2 is %s", vec_to_str(level.vertex_position(vertex)))
|
||||
|
||||
end
|
||||
function act_state_mgr_smartcover_exit:execute()
|
||||
action_base.execute(self)
|
||||
end
|
||||
function act_state_mgr_smartcover_exit:finalize()
|
||||
action_base.finalize(self)
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue