злойлеший 0 Опубликовано 29 Июля 2016 Всем доброго времени суток. В чистую ТЧ сделал себе, по статьям из вики, спальник и ремкомплект. По отдельности они работают без проблем, но при соединении в одну геймдату работает только спальник. Совместно ими используется только bind_stalker.script. function init (obj) xr_motivator.AddToMotivator(obj)endfunction actor_init (npc)npc:bind_object(actor_binder(npc))endlocal game_difficulty_by_num = {[0] = "gd_novice",[1] = "gd_stalker",[2] = "gd_veteran",[3] = "gd_master"}lasthealth = 0lasttime = 0post_process = 0local weapon_hide = false----------------------------------------------------------------------------------------------------------------------class "actor_binder" (object_binder)----------------------------------------------------------------------------------------------------------------------function actor_binder:__init (obj) super(obj)self.bCheckStart = falseself.weather_manager = level_weathers.WeatherManager()self.actor_detector = xr_detector.actor_detector()end----------------------------------------------------------------------------------------------------------------------function actor_binder:net_spawn(data)printf("actor net spawn")level.show_indicators()self.bCheckStart = trueself.weapon_hide = false -- спрятано или нет оружие при разговоре.weapon_hide = false -- устанавливаем глобальный дефолтовый флаг.if object_binder.net_spawn(self,data) == false thenreturn falseenddb.add_actor(self.object)if self.st.disable_input_time == nil thenlevel.enable_input()endself.weather_manager:reset()-- game_stats.initialize ()if(actor_stats.add_to_ranking~=nil)thenactor_stats.add_to_ranking(self.object:id())end--' Загружаем настройки дропаdeath_manager.init_drop_settings()return trueend----------------------------------------------------------------------------------------------------------------------function actor_binder:net_destroy()if(actor_stats.remove_from_ranking~=nil)thenactor_stats.remove_from_ranking(self.object:id())end-- game_stats.shutdown ()db.del_actor(self.object)sr_light.clean_up ()self.object:set_callback(callback.inventory_info, nil)self.object:set_callback(callback.article_info, nil)self.object:set_callback(callback.on_item_take, nil)self.object:set_callback(callback.on_item_drop, nil)--self.object:set_callback(callback.actor_sleep, nil)self.object:set_callback(callback.task_state, nil)self.object:set_callback(callback.level_border_enter, nil)self.object:set_callback(callback.level_border_exit, nil)self.object:set_callback(callback.take_item_from_box, nil)self.object:set_callback(callback.use_object, nil)if sr_psy_antenna.psy_antenna thensr_psy_antenna.psy_antenna:destroy()sr_psy_antenna.psy_antenna = falseendxr_sound.stop_all_sound_object()object_binder.net_destroy(self)end----------------------------------------------------------------------------------------------------------------------function actor_binder:reinit()object_binder.reinit(self)local npc_id = self.object:id()db.storage[npc_id] = { }self.st = db.storage[npc_id]self.st.pstor = nilself.next_restrictors_update_time = -10000self.object:set_callback(callback.inventory_info, self.info_callback, self)self.object:set_callback(callback.article_info, self.article_callback, self)self.object:set_callback(callback.on_item_take, self.on_item_take, self)self.object:set_callback(callback.on_item_drop, self.on_item_drop, self)self.object:set_callback(callback.trade_sell_buy_item, self.on_trade, self) -- for game stats--self.object:set_callback(callback.actor_sleep, self.sleep_callback, self)self.object:set_callback(callback.task_state, self.task_callback, self)--self.object:set_callback(callback.map_location_added, self.map_location_added_callback, self)self.object:set_callback(callback.level_border_enter, self.level_border_enter, self)self.object:set_callback(callback.level_border_exit, self.level_border_exit, self)self.object:set_callback(callback.take_item_from_box, self.take_item_from_box, self)self.object:set_callback(callback.use_object, self.use_object, self)self.object:set_callback(callback.use_object, self.repair_outfit_start, self)end----------------------------------------------------------------------------------------------------------------------function actor_binder:take_item_from_box(box, item)local story_id = box:story_id()if story_id == nil thenreturnendtreasure_manager.take_item_from_box(box, story_id)--[[local respawner = se_respawn.get_respawner_by_parent(story_id)if respawner == nil thenreturnend--' Необходимо уменьшить счетчик в респавнереrespawner:remove_spawned(item:id())local smart_terrain = db.strn_by_respawn[respawner:name()]if smart_terrain == nil thenreturnendlocal npc = smart_terrain.gulag:get_nearest_online_obj(db.actor:position())if npc ~= nil thenxr_sound.set_sound_play(npc, "reac_box")xr_gulag.setGulagEnemy(smart_terrain:name() , db.actor)end]]end----------------------------------------------------------------------------------------------------------------------function actor_binder:level_border_enter(npc, info_id)self.actor_detector:actor_enter()end----------------------------------------------------------------------------------------------------------------------function actor_binder:level_border_exit(npc, info_id)self.actor_detector:actor_exit()end----------------------------------------------------------------------------------------------------------------------function actor_binder:info_callback(npc, info_id)printf("*INFO*: npc='%s' id='%s'", npc:name(), info_id)--' Сюжетlevel_tasks.proceed(self.object)-- Отметки на картеlevel_tasks.process_info_portion(info_id)end----------------------------------------------------------------------------------------------------------------------function actor_binder:on_trade (item, sell_bye, money)if sell_bye == true thengame_stats.money_trade_update (money)elsegame_stats.money_trade_update (-money)endend----------------------------------------------------------------------------------------------------------------------function actor_binder:article_callback(npc, group, name)--printf("article_callback [%s][%s]", group, name)if device().precache_frame >1 then return endif group == "Diary" thennews_manager.send_encyclopedy("diary", group)elsenews_manager.send_encyclopedy("encyclopedy", group)endend----------------------------------------------------------------------------------------------------------------------function actor_binder:on_item_take (obj)level_tasks.proceed(self.object)--game_stats.update_take_item (obj, self.object)end----------------------------------------------------------------------------------------------------------------------function actor_binder:on_item_drop (obj)level_tasks.proceed(self.object)--game_stats.update_drop_item (obj, self.object)endfunction actor_binder:use_obj(obj)main_sleep.sleep(obj)end----------------------------------------------------------------------------------------------------------------------function actor_binder:task_callback(_task, _objective, _state)task_manager.task_callback(_task:get_id(), _objective:get_idx(), _state)if _objective:get_idx() == 0 thenif _state == task.fail thennews_manager.send_task(db.actor, "fail", _task, _objective)elseif _state == task.completed thentask_manager.reward_by_task(_task)news_manager.send_task(db.actor, "complete", _task, _objective)elsenews_manager.send_task(db.actor, "new", _task, _objective)endelseif _task:get_objective(0):get_state() == task.in_progress thennews_manager.send_task(db.actor, "update", _task, _objective)endendend----------------------------------------------------------------------------------------------------------------------function actor_binder:map_location_added_callback(spot_type_str, object_id)if (false==app_ready()) or (device().precache_frame>1) then return end--'news_manager.send_task(db.actor, "new")end----------------------------------------------------------------------------------------------------------------------function actor_binder:update(delta)object_binder.update(self, delta)-- DEBUG slowdown-- slowdown.update()local time = time_global()game_stats.update (delta, self.object)show_time.show_time()-- апдейт погодыself.weather_manager:update()-- апдейт схемы детектораself.actor_detector:update()-- апдейт звуковой схемы актераxr_sound.update_actor()--' Проверка потери жизни--[[if self.object.health - lasthealth > 0.001 orself.object.health - lasthealth < -0.001 thenprintf("%f | %f", self.object.health, self.object.health - lasthealth, game.time() - lasttime)lasthealth = self.object.healthlasttime = game.time()end]]-- Обновление отключения ввода с клавиатуры.if self.st.disable_input_time ~= nil andgame.get_game_time():diffSec(self.st.disable_input_time) >= self.st.disable_input_idlethenlevel.enable_input()self.st.disable_input_time = nilend-- Обновление сна с переносом чувака в указанную позициюif self.st.sleep_relocate_time ~= nil andgame.get_game_time():diffSec(self.st.sleep_relocate_time) >= self.st.sleep_relocate_idlethenself.object:set_actor_position(self.st.sleep_relocate_point)local dir = self.st.sleep_relocate_point:sub(self.st.sleep_relocate_look)self.object:set_actor_direction(dir:getH())self.st.sleep_relocate_time = nilend-- Апдейт прятание оружия игрока во время диалогаif weapon_hide == true or self.object:is_talking() thenif self.weapon_hide == false thenself.object:hide_weapon()self.weapon_hide = trueendelseif self.weapon_hide == true thenself.object:restore_weapon()self.weapon_hide = falseendend-- обновление рестрикторов, которые под логикой, срабатывает через интервалы времениif self.next_restrictors_update_time < time thenbind_restrictor.actor_update(delta)self.next_restrictors_update_time = time + 200task_manager.actor_update()end-- обновление постпроцессовif post_process ~= 0 thenif post_process:update () == true thenpost_process = 0endend-- обновление пси-антенныif sr_psy_antenna.psy_antenna thensr_psy_antenna.psy_antenna:update(delta)end--' Вывод сообщения о большой радиацииif self.object.radiation >= 0.7 thenlocal hud = get_hud()local custom_static = hud:GetCustomStatic("cs_radiation_danger")if custom_static == nil thenhud:AddCustomStatic("cs_radiation_danger", true)hud:GetCustomStatic("cs_radiation_danger"):wnd():SetTextST("st_radiation_danger")endelselocal hud = get_hud()local custom_static = hud:GetCustomStatic("cs_radiation_danger")if custom_static ~= nil thenhud:RemoveCustomStatic("cs_radiation_danger")endendif self.bCheckStart thenprintf("SET DEFAULT INFOS")if not has_alife_info("storyline_actor_start") and(level.name() == "l01_escape")thenself.object:give_info_portion("storyline_actor_start")_G.g_start_avi = trueprintf("*AVI* RUN START AVI")end-- if not has_alife_info("encyclopedy") then-- self.object:give_info_portion("encyclopedy")-- endif not has_alife_info("global_dialogs") thenself.object:give_info_portion("global_dialogs")endif not has_alife_info("level_changer_icons") thenself.object:give_info_portion("level_changer_icons")endlevel_tasks.add_lchanger_location()self.bCheckStart = falseend--autosave.save_update()end----------------------------------------------------------------------------------------------------------------------function actor_binder:save(packet)local save_treasure_manager = trueprintf("actor_binder:save(): self.object:name()='%s'", self.object:name())object_binder.save(self, packet)--' Сохраняем уровень сложностиif save_treasure_manager == true thenpacket:w_u8(level.get_game_difficulty() + 128)elsepacket:w_u8(level.get_game_difficulty())end--' Сохраняем данные об отключенном вводеif self.st.disable_input_time == nil thenpacket:w_bool(false)elsepacker:w_bool(true)utils.w_CTime(packet, self.st.disable_input_time)endxr_logic.pstor_save_all(self.object, packet)self.weather_manager:save(packet)sr_psy_antenna.save( packet )if save_treasure_manager == true thentreasure_manager.save(packet)endtask_manager.save(packet)self.actor_detector:save(packet)end----------------------------------------------------------------------------------------------------------------------function actor_binder:load(reader)printf("actor_binder:load(): self.object:name()='%s'", self.object:name())object_binder.load(self, reader)printf("actor_binder:object_binder.load(): self.object:name()='%s'", self.object:name())--' Загружаем уровень сложностиlocal game_difficulty = reader:r_u8()local load_treasure_manager = falseif game_difficulty >= 128 thengame_difficulty = game_difficulty - 128load_treasure_manager = trueendget_console():execute("g_game_difficulty "..game_difficulty_by_num[game_difficulty])if reader:r_eof() thenabort("SAVE FILE IS CORRUPT")endlocal stored_input_time = reader:r_u8()if stored_input_time == true thenself.st.disable_input_time = utils.r_CTime(reader)endxr_logic.pstor_load_all(self.object, reader)self.weather_manager:load(reader)sr_psy_antenna.load(reader)if load_treasure_manager == true thentreasure_manager.load(reader)endtask_manager.load(reader)self.actor_detector:load(reader)endfunction actor_binder:repair_outfit_start(obj, who)if obj thenif obj:section() == "abc_repair" thenremkomplekt.action_repair()endendend------------------------------------------------------------------------------------------------------------------------старт префетча звуков--if string.find(command_line(), "-noprefetch") == nil then-- sound_prefetch.prefetch_sounds()--end-- Weapon functionsfunction hide_weapon()weapon_hide = trueendfunction restore_weapon()weapon_hide = falseend// this is test for section iteration/**local function test_section_iteration(file_name, section_name)printf ("file : %s",file_name)printf ("section : %s",section_name)local file = ini_file(file_name)local n = file:line_count(section_name)printf ("lines : %d",n)local id, value = "", "", resultfor i=0,n-1 doresult, id, value = file:r_line(section_name,i,"","")printf ("line %d : %s = %s",i,id,value)endendtest_section_iteration("system.ltx","space_restrictor")/**/ Вопрос как их заставить работать в одном моде? Поделиться этим сообщением Ссылка на сообщение