---------------------------------------------------------------------------------------------------------------------- --Actions ---------------------------------------------------------------------------------------------------------------------- -- Обычное поведение class "action_process_death" function action_process_death:__init(obj, storage) self.object = obj self.st = storage end function action_process_death:death_callback(victim, who) if who ~= nil then printf("[%s] killed by [%s]", victim:name(), who:name() ) db.storage[victim:id()].death.killer = who:id() else printf("[%s] killed by [Unknown]", victim:name()) db.storage[victim:id()].death.killer = -1 end if db.actor then if self.st.info then xr_logic.pick_section_from_condlist(db.actor, self.object, self.st.info) end if self.st.info2 then xr_logic.pick_section_from_condlist(db.actor, self.object, self.st.info2) end end end ---------------------------------------------------------------------------------------------------------------------- -- binder ---------------------------------------------------------------------------------------------------------------------- function add_to_binder(npc, ini, scheme, section, storage) local action = this.action_process_death(npc, storage) xr_logic.subscribe_action_for_events(npc, storage, action) end function set_death(npc, ini, scheme, section) local st = xr_logic.assign_storage_and_bind(npc, ini, scheme, section) end function reset_death(npc, scheme, st, section) local death_section = utils.cfg_get_string(st.ini, st.section_logic, "on_death", npc, false, "") -- printf("reset death for [%s]", npc:name()) if death_section then if not st.ini:section_exist(death_section) then abort("There is no section [%s] for npc [%s]", death_section, npc:name()) end -- printf("reset death, section present") local tmp = utils.cfg_get_string(st.ini, death_section, "on_info", npc, false, "") -- printf("tmp [%s]", tostring(tmp)) if tmp then st.death.info = xr_logic.parse_condlist(npc, death_section, "death", tmp) end -- printf("tmp [%s]", tostring(tmp)) tmp = utils.cfg_get_string(st.ini, death_section, "on_info2", npc, false, "") if tmp then st.death.info2 = xr_logic.parse_condlist(npc, death_section, "death", tmp) end end end