--' Схема: детектор на опасную зону: граница уровня. --' dead_zone.ppe local start_time = 0 --'Время, с которого начинается возрастание интенсивности local max_time = 100 --'Время, в которое интенсивность станет максимальной local threshold = 0.2 --'Порог, с которого начинается заражение local idle_time = 10 --'Время между хитами. В игровых секундах. class "actor_detector" function actor_detector:__init() self.init_time = -1 end function actor_detector:actor_enter() --' Игрок покидает опасную территорию (входит в разрешенную границу уровня) -- self.init_time = -1 -- level.remove_pp_effector(1001) end function actor_detector:actor_exit() --' Игрок входит на опасную территорию (покидает разрешенную границу уровня) -- self.init_time = game.get_game_time() -- level.add_pp_effector("dead_zone.ppe", 1001, true) -- level.set_pp_effector_factor(1001, 0.01) -- self.last_update_time = game.get_game_time() end function actor_detector:update() --' Апдейтим игрока и устанавливаем действия. if self.init_time == -1 then return end if game.get_game_time():diffSec(self.last_update_time) < idle_time then return end self.last_update_time = game.get_game_time() --' В зависимости от времени нахождения игрока внутри возрастает интенсивность. --' Интенсивность возрастает от 0 до 1. При достижении порога начинает хитовать радиация. local intence = math.min(1,math.max(0.01,game.get_game_time():diffSec(self.init_time)/(max_time - start_time))) level.set_pp_effector_factor(1001, intence, 0.3) printf("INTENCE %s", intence) if intence > threshold then local h = hit() h.draftsman = db.actor h.type = hit.radiation h.power = 0.05 db.actor:hit(h) end end function actor_detector:save(packet) set_save_marker(packet, "save", false, "actor_detector") if self.init_time == -1 then packet:w_u8(0) else packet:w_u8(1) utils.w_CTime(packet, self.init_time) utils.w_CTime(packet, self.last_update_time) end set_save_marker(packet, "save", true, "actor_detector") end function actor_detector:load(packet) set_save_marker(packet, "load", false, "actor_detector") local flag = packet:r_u8() if flag == 1 then self.init_time = utils.r_CTime(packet) self.last_update_time = utils.r_CTime(packet) else self.init_time = -1 end set_save_marker(packet, "load", true, "actor_detector") end