--' Находится ли уже смарткавер в нужном состоянии 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