--[[ Изменения script_version: 3 - сохранение поля job_online 5 - сохранение поля was_in_smart_terrain 6 - сохранение поля death_droped ]] class "se_stalker" (cse_alife_human_stalker) -------------------- function se_stalker:__init (section) super (section) self.ini = nil self.ini_initialized = false self.smart_terrain_conditions = nil self.smart_terrain_conditions_initialized = false -- этот флаг берётся из работы смарта -- true = всегда в онлайне -- false = всегда в офлайне -- condlist = условие, которое отпределяет true или false -- nil = смарту всё равно self.job_online = nil self.job_online_condlist = nil self.death_droped = false --'Генерил ли персонаж выпадаемые предметы или нет. self.m_registred = false self.sim_forced_online = false if db.offline_objects[self.id] == nil then db.offline_objects[self.id] = {} end self.board = sim_board.get_sim_board() end -------------------- function se_stalker:get_ini() if not self.ini_initialized then self.ini = self:spawn_ini() self.ini_initialized = true end end -------------------- function se_stalker:can_switch_offline() if self.group_id ~= 65535 then return true end return cse_alife_human_stalker.can_switch_offline(self) end -------------------- function se_stalker:can_switch_online() if self.group_id ~= 65535 then return true end return cse_alife_human_stalker.can_switch_online(self) end function se_stalker:switch_online() cse_alife_human_stalker.switch_online(self) end function se_stalker:switch_offline() cse_alife_human_stalker.switch_offline(self) end -------------------- function se_stalker:STATE_Write(packet) cse_alife_human_stalker.STATE_Write (self, packet) if self.online then packet:w_stringZ(tostring(level and level.object_by_id(self.id) and level.object_by_id(self.id):level_vertex_id())) else packet:w_stringZ(tostring(db.offline_objects[self.id] and db.offline_objects[self.id].level_vertex_id)) end packet:w_stringZ(tostring(db.offline_objects[self.id] and db.offline_objects[self.id].active_section)) packet:w_bool(self.death_droped ) end -------------------- function se_stalker:STATE_Read(packet, size) cse_alife_human_stalker.STATE_Read (self, packet, size) if self.script_version > 10 then local old_lvid = packet:r_stringZ() if db.offline_objects[self.id] == nil then db.offline_objects[self.id] = {} end db.offline_objects[self.id].active_section = packet:r_stringZ() if db.offline_objects[self.id].active_section == "nil" then db.offline_objects[self.id].active_section = nil end if old_lvid ~= "nil" then db.offline_objects[self.id].level_vertex_id = tonumber(old_lvid) end end self.death_droped = packet:r_bool() end -------------------- function se_stalker:on_before_register() end -------------------- function se_stalker:on_register() cse_alife_human_stalker.on_register( self ) -- Проверяем кастомдату обьекта на наличие стори айди. story_objects.check_spawn_ini_for_story_id(self) self.board = sim_board.get_sim_board() local obj_ini = self:spawn_ini() self.m_registred = true if db.offline_objects[self.id] == nil then db.offline_objects[self.id] = {} end -- db.offline_objects[self.id].level_vertex_id = self.m_level_vertex_id printf("registering stalker %s ", self:name()) --' Отключаем старый метод выбора смарттеррейнов. self:brain():can_choose_alife_tasks(false) --' Выбор смарта local smart = utils.cfg_get_string(obj_ini, "logic", "smart_terrain", self, false, "", "") local smart_obj = self.board:get_smart_by_name(smart) if smart_obj == nil then return end alife():object(smart_obj.id):register_npc(self) end -------------------- function se_stalker:on_unregister() local strn_id = self:smart_terrain_id() if strn_id ~= 65535 then local smart = alife():object(strn_id) if smart ~= nil then smart:unregister_npc(self) end end db.offline_objects[self.id] = nil unregister_story_object_by_id(self.id) cse_alife_human_stalker.on_unregister(self) end -------------------- function se_stalker:on_spawn() cse_alife_human_stalker.on_spawn(self) end -------------------- function se_stalker:on_death(killer) cse_alife_human_stalker.on_death(self, killer) smart_terrain.on_death(self) if self.group_id ~= 65535 then local squad = alife():object(self.group_id) if squad == nil then --printf("sim_board squads") --print_table(self.board.squads) abort("There is no squad with ID [%s]", self.group_id) end squad:on_npc_death(self) end end -------------------- function se_stalker:update() cse_alife_human_stalker.update(self) end