Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
208
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- nv120412 support for Rulix/xStream's AI - ZRP-compatible version
  2. -- Modders: if bind_stalker.script is not valid, actor will be nil
  3. function init (obj)
  4. xr_motivator.AddToMotivator(obj)
  5. end
  6.  
  7. function actor_init (npc)
  8. npc:bind_object(actor_binder(npc))
  9. end
  10.  
  11. local game_difficulty_by_num = {
  12. [0] = "gd_novice",
  13. [1] = "gd_stalker",
  14. [2] = "gd_veteran",
  15. [3] = "gd_master"
  16. }
  17.  
  18. -- nv130228 - added bind_stalker.quitting_game var to keep game from processing dropped items
  19. quitting_game = false
  20.  
  21. -- debug flag (normally set by player in main menu; requires _z.script)
  22. nv_debug = false
  23. -- this is set true if tick update is needed (TM loss_workaround, ammo_fix, etc.)
  24. nv_need_update = false
  25. -- this is set true by events needing longer time delays
  26. nv_timer_pending = false
  27. -- time-on-hud flag (normally set by player via Modifier; requires _z.script)
  28. local nv_show_time = false
  29. -- set this true to automatically copy or rename autosaves to level_autosaves
  30. local level_autosaves = true
  31. -- set this true to rename autosave, false to copy it (if level_autosaves = true)
  32. local rename_autosave = true
  33. -- set this true to preserve your first access to a level if level_autosaves = true
  34. local keep_first_level_access = true
  35. -- set this true to preserve your first access to a level after key progress points
  36. local keep_progress_level_access = true
  37. -- set true if you want to use a sleeping bag in the game (see docs)
  38. local use_sleeping_bag = true
  39.  
  40. -- lasthealth = 0
  41. -- lasttime = 0
  42. -- post_process = 0
  43. local weapon_hide = false
  44. local autosave_prefix
  45. ----------------------------------------------------------------------------------------------------------------------
  46. class "actor_binder" (object_binder)
  47. ----------------------------------------------------------------------------------------------------------------------
  48. function actor_binder:__init (obj) super(obj)
  49. self.bCheckStart = false
  50. self.weather_manager = level_weathers.WeatherManager()
  51. self.actor_detector = xr_detector.actor_detector()
  52. autosave_prefix = ui_main_menu.save_prefix
  53. if autosave_prefix == nil then autosave_prefix = "" end
  54. end
  55. ----------------------------------------------------------------------------------------------------------------------
  56. function actor_binder:net_spawn(data)
  57. -- printf("actor net spawn")
  58.  
  59. level.show_indicators()
  60.  
  61. self.bCheckStart = true
  62. self.weapon_hide = false -- ńļš˙ņąķī čėč ķåņ īšóęčå ļšč šąēćīāīšå.
  63. weapon_hide = false -- óńņąķąāėčāąåģ ćėīįąėüķūé äåōīėņīāūé ōėąć.
  64.  
  65. if object_binder.net_spawn(self,data) == false then
  66. return false
  67. end
  68.  
  69. db.add_actor(self.object)
  70. -- nv100217 permanent radiation cure
  71. if self.actor_detector.init_time ~= -1 then
  72. self.actor_detector:actor_enter()
  73. dbglog("Permanent radiation bug fix applied")
  74. end
  75.  
  76. if self.st.disable_input_time == nil then
  77. level.enable_input()
  78. end
  79.  
  80. self.weather_manager:reset()
  81. -- game_stats.initialize ()
  82.  
  83. if(actor_stats.add_to_ranking~=nil)then
  84. actor_stats.add_to_ranking(self.object:id())
  85. end
  86.  
  87. --' Ēąćšóęąåģ ķąńņšīéźč äšīļą
  88. death_manager.init_drop_settings()
  89.  
  90. if xrs_ai then xrs_ai.actor_net_spawn(self) end
  91. if rx_ai then rx_ai.actor_net_spawn() end
  92.  
  93. return true
  94. end
  95. ----------------------------------------------------------------------------------------------------------------------
  96. function actor_binder:net_destroy()
  97. _z.remove_debug_static()
  98. _z.remove_time_static()
  99. if(actor_stats.remove_from_ranking~=nil)then
  100. actor_stats.remove_from_ranking(self.object:id())
  101. end
  102. -- game_stats.shutdown ()
  103. db.del_actor(self.object)
  104.  
  105. sr_light.clean_up ()
  106.  
  107. self.object:set_callback(callback.inventory_info, nil)
  108. self.object:set_callback(callback.article_info, nil)
  109. self.object:set_callback(callback.on_item_take, nil)
  110. self.object:set_callback(callback.on_item_drop, nil)
  111. --self.object:set_callback(callback.actor_sleep, nil)
  112. self.object:set_callback(callback.task_state, nil)
  113. self.object:set_callback(callback.level_border_enter, nil)
  114. self.object:set_callback(callback.level_border_exit, nil)
  115. self.object:set_callback(callback.take_item_from_box, nil)
  116. self.object:set_callback(callback.use_object, nil)
  117. self.object:set_callback(callback.death, nil)
  118.  
  119. if sr_psy_antenna.psy_antenna then
  120. sr_psy_antenna.psy_antenna:destroy()
  121. sr_psy_antenna.psy_antenna = false
  122. end
  123.  
  124. xr_sound.stop_all_sound_object()
  125.  
  126. object_binder.net_destroy(self)
  127. end
  128. ----------------------------------------------------------------------------------------------------------------------
  129. function actor_binder:reinit()
  130. object_binder.reinit(self)
  131.  
  132. local npc_id = self.object:id()
  133.  
  134. db.storage[npc_id] = { }
  135.  
  136. self.st = db.storage[npc_id]
  137. self.st.pstor = nil
  138.  
  139. self.next_restrictors_update_time = -10000
  140.  
  141. self.object:set_callback(callback.inventory_info, self.info_callback, self)
  142. self.object:set_callback(callback.article_info, self.article_callback, self)
  143. self.object:set_callback(callback.on_item_take, self.on_item_take, self)
  144. self.object:set_callback(callback.on_item_drop, self.on_item_drop, self)
  145. -- self.object:set_callback(callback.trade_sell_buy_item, self.on_trade, self) -- for game stats
  146. --self.object:set_callback(callback.actor_sleep, self.sleep_callback, self)
  147. self.object:set_callback(callback.task_state, self.task_callback, self)
  148. --self.object:set_callback(callback.map_location_added, self.map_location_added_callback, self)
  149. self.object:set_callback(callback.level_border_enter, self.level_border_enter, self)
  150. self.object:set_callback(callback.level_border_exit, self.level_border_exit, self)
  151. self.object:set_callback(callback.take_item_from_box, self.take_item_from_box, self)
  152. self.object:set_callback(callback.use_object, self.use_object, self)
  153. self.object:set_callback(callback.death, self.on_death, self)
  154. --play sound when using item in inventory
  155. self.object:set_callback(callback.use_object, self.on_use_item, self)
  156. end
  157.  
  158. -- new method, will be called every time you use item in inventory
  159. function actor_binder:on_use_item(obj)
  160. item_usage.on_use_item(obj)
  161. end
  162. ----------------------------------------------------------------------------------------------------------------------
  163. -- use this (and the use_object set_callback()s above) if you want to handle object use
  164. function actor_binder:use_object(object)
  165. lurk_inv_effects.start(object)
  166. dbglog("use_object_%s,_section_%s",object:name(), object:section())
  167. end
  168. ----------------------------------------------------------------------------------------------------------------------
  169. function actor_binder:on_death(object)
  170. -- _z.nvDebug("You are dead.")
  171. -- kill all the controllers to eliminate the roar
  172. if _z.kill_online_controllers() > 0 then -- returns kill_count
  173. --_z.nvDebug("So are the controllers.")
  174. _z.show_blinking_msg("Please wait for any controller noise to fade.")
  175. end
  176. level.enable_input() -- for death while sleeping
  177. end
  178. ----------------------------------------------------------------------------------------------------------------------
  179. function actor_binder:take_item_from_box(box, item)
  180. local story_id = box:story_id()
  181. if story_id == nil then
  182. return
  183. end
  184.  
  185. if story_id >= 5000 then
  186. treasure_manager.take_item_from_box(box, story_id)
  187. return
  188. end
  189. if _custom_ext then
  190. _custom_ext.on_take_item_from_box(box, item, story_id)
  191. end
  192.  
  193. -- nv150313 re-enabled this as a better way to manage inventory box maximum amounts
  194. local respawner = se_respawn.get_respawner_by_parent(story_id)
  195. if respawner == nil then
  196. return
  197. end
  198.  
  199. --' Ķåīįõīäčģī óģåķüųčņü ń÷åņ÷čź ā šåńļąāķåšå
  200. respawner:remove_spawned(item:id())
  201.  
  202. --[[
  203. local smart_terrain = db.strn_by_respawn[respawner:name()]
  204. if smart_terrain == nil then
  205. return
  206. end
  207.  
  208. local npc = smart_terrain.gulag:get_nearest_online_obj(db.actor:position())
  209. if npc ~= nil then
  210. xr_sound.set_sound_play(npc, "reac_box")
  211. xr_gulag.setGulagEnemy(smart_terrain:name() , db.actor)
  212. end
  213. ]]
  214. end
  215. ----------------------------------------------------------------------------------------------------------------------
  216. function actor_binder:level_border_enter(npc, info_id)
  217. self.actor_detector:actor_enter()
  218. end
  219. ----------------------------------------------------------------------------------------------------------------------
  220. function actor_binder:level_border_exit(npc, info_id)
  221. self.actor_detector:actor_exit()
  222. end
  223. ----------------------------------------------------------------------------------------------------------------------
  224. function actor_binder:info_callback(npc, info_id)
  225. if info_id == "ui_car_body" then
  226. xr_sound.get_safe_sound_object( "interface\\inv_open" ):play_no_feedback( db.actor, sound_object.s2d, 0, vector(), 1.0 )
  227. elseif info_id == "ui_car_body_hide" then
  228. xr_sound.get_safe_sound_object( "interface\\inv_close" ):play_no_feedback( db.actor, sound_object.s2d, 0, vector(), 1.0 )
  229. end
  230. -- printf("*INFO*: npc='%s' id='%s'", npc:name(), info_id)
  231. --' Ńžęåņ
  232. level_tasks.proceed(self.object)
  233. -- Īņģåņźč ķą źąšņå
  234. level_tasks.process_info_portion(info_id)
  235. end
  236. ----------------------------------------------------------------------------------------------------------------------
  237. --[[ restore if you need the function, but you probably don't need the game_stats stuff
  238. function actor_binder:on_trade (item, sell_bye, money)
  239. -- if sell_bye == true then
  240. -- -- game_stats.money_trade_update (money)
  241. -- else
  242. -- -- game_stats.money_trade_update (-money)
  243. -- end
  244. end
  245. --]]
  246. ----------------------------------------------------------------------------------------------------------------------
  247. function actor_binder:article_callback(npc, group, name)
  248. --printf("article_callback [%s][%s]", group, name)
  249. if device().precache_frame >1 then return end
  250.  
  251. if group == "Diary" then
  252. -- fix per Cpt. Borovich -- now 100% more annoying
  253. news_manager.send_encyclopedy(group, "diary")
  254. else
  255. news_manager.send_encyclopedy(group, "encyclopedy")
  256. end
  257. end
  258. ----------------------------------------------------------------------------------------------------------------------
  259. function actor_binder:on_item_take (obj)
  260. if has_alife_info( "ui_car_body" ) then
  261. xr_sound.get_safe_sound_object( "interface\\inv_ruck" ):play_no_feedback( db.actor, sound_object.s2d, 0, vector(), 1.0 )
  262. end
  263. if obj:clsid() ~= clsid.wpn_ammo then
  264. level_tasks.proceed(self.object)
  265. end
  266. if device().precache_frame >1 then return end
  267. if xrs_ai then xrs_ai.actor_item_take(obj) end
  268. if rx_ai then rx_ai.actor_item_take(obj) end
  269. --game_stats.update_take_item (obj, self.object)
  270. _z.on_item_take(obj, self.object)
  271. end
  272. ----------------------------------------------------------------------------------------------------------------------
  273. function actor_binder:on_item_drop (obj)
  274. if has_alife_info( "ui_car_body" ) then
  275. xr_sound.get_safe_sound_object( "interface\\inv_drop" ):play_no_feedback( db.actor, sound_object.s2d, 0, vector(), 1.0 )
  276. end
  277. if quitting_game then return end
  278. if obj:clsid() ~= clsid.wpn_ammo then
  279. level_tasks.proceed(self.object)
  280. end
  281. --game_stats.update_drop_item (obj, self.object)
  282. if _z.item_drop_is_intentional(obj, self.object) then
  283. if _z.on_item_drop(obj, self.object) then return end -- true = used item
  284. if use_sleeping_bag and abc_sleep and obj:section()=="sleep_bag" then
  285. if not has_alife_info("ui_inventory") then return end
  286. if _dev then
  287. _dev.queue_delayed_event({delay=1200,event="abc_sleep.show_sleep_dialog()"})
  288. else
  289. dbglog("sleep_bag needs valid _dev.script")
  290. end
  291. end
  292. end
  293. end
  294. ----------------------------------------------------------------------------------------------------------------------
  295. function actor_binder:task_callback(_task, _objective, _state)
  296. task_manager.task_callback(_task:get_id(), _objective:get_idx(), _state)
  297. _z.task_mapspot_cleanup(_task:get_id(), _objective:get_idx(), _state)
  298. if _objective:get_idx() == 0 then
  299. if _state == task.fail then
  300. news_manager.send_task(db.actor, "fail", _task, _objective)
  301. elseif _state == task.completed then
  302. task_manager.reward_by_task(_task)
  303. news_manager.send_task(db.actor, "complete", _task, _objective)
  304. else
  305. news_manager.send_task(db.actor, "new", _task, _objective)
  306. end
  307. else
  308. if _task:get_objective(0):get_state() == task.in_progress then
  309. news_manager.send_task(db.actor, "update", _task, _objective)
  310. end
  311. end
  312. end
  313. ----------------------------------------------------------------------------------------------------------------------
  314. -- function actor_binder:map_location_added_callback(spot_type_str, object_id)
  315. -- if (false==app_ready()) or (device().precache_frame>1) then return end
  316. -- --'news_manager.send_task(db.actor, "new")
  317. -- end
  318. ----------------------------------------------------------------------------------------------------------------------
  319. -- nv111103 check for autosave level copy or rename
  320. -- nv130223 rename fail check, optional progress autosaves added
  321. function manage_autosaves()
  322. local fs = getFS()
  323. local autosaveFile = string.lower(user_name()).."_autosave"
  324. local autosaveFile_sav = autosaveFile .. ".sav"
  325. local fs_path = "$game_saves$"
  326. if fs:exist(fs_path, autosaveFile_sav) then
  327. local sg = CSavedGameWrapper(autosaveFile)
  328. local level_name = level.name()
  329. if level_name == sg:level_name() then
  330. local target = autosave_prefix .. level_name .."_autosave"
  331. local target_save = target .. ".sav"
  332. -- update_path info per fluffy22
  333. local savedir = fs:update_path(fs_path, "")
  334. local target_exists = fs:exist(fs_path, target_save)
  335. if target_exists and sg:game_time() < CSavedGameWrapper(target):game_time() then
  336. return -- current autosave is earlier in-game time
  337. end
  338. if rename_autosave then
  339. fs:file_rename(savedir..autosaveFile_sav, savedir..target_save, true)
  340. else
  341. if target_exists then fs:file_delete(savedir..target_save) end
  342. fs:file_copy(savedir..autosaveFile_sav, savedir..target_save)
  343. end
  344. -- nv130223 keep game from attempting to load non-existent save if rename failed
  345. if fs:exist(fs_path, target_save) then get_console():execute("load_last_save "..target) end
  346. if keep_first_level_access then
  347. local first_target = autosave_prefix .. level_name -- .." - start.sav"
  348. local postfix = " - start.sav"
  349. if keep_progress_level_access then
  350. if level_name == "l01_escape" then
  351. if not has_alife_info("bar_darklab_document_gain") then
  352. return -- all.sav already made
  353. end
  354. postfix = "_post_x18_autosave.sav"
  355. elseif level_name == "l04_darkvalley" and has_alife_info("bar_darklab_document_gain") then
  356. postfix = "_post_x18_autosave.sav"
  357. elseif level_name == "l08_yantar" and has_alife_info("yan_x16_documents_gain") then
  358. postfix = "_post_x16_autosave.sav"
  359. elseif level_name == "l10_radar" and has_alife_info("bar_deactivate_radar_done") then
  360. postfix = "_post_x19_autosave.sav"
  361. --else use as is
  362. end
  363. else
  364. if level_name == "l01_escape" then return end
  365. end
  366. first_target = first_target..postfix
  367. if not fs:exist(fs_path, first_target) then
  368. if fs:exist(fs_path, target_save) then
  369. fs:file_copy(savedir..target_save, savedir..first_target)
  370. end
  371. end
  372. end
  373. end
  374. end
  375. end
  376. ----------------------------------------------------------------------------------------------------------------------
  377. function actor_binder:update(delta)
  378. lurk_inv_effects.weapontimer()
  379. object_binder.update(self, delta)
  380.  
  381. -- DEBUG slowdown
  382. -- slowdown.update()
  383.  
  384. local time = time_global()
  385.  
  386. -- nv 100521 moved this below to reduce processing
  387. -- game_stats.update (delta, self.object)
  388.  
  389. -- ąļäåéņ ļīćīäū
  390. self.weather_manager:update()
  391.  
  392. -- nv 100521 moved this below to reduce processing
  393. -- ąļäåéņ ńõåģū äåņåźņīšą
  394. -- self.actor_detector:update()
  395.  
  396. -- ąļäåéņ ēāóźīāīé ńõåģū ąźņåšą
  397. xr_sound.update_actor()
  398. rx_shoot_enable.shoot_effect()
  399.  
  400. --' Ļšīāåšźą ļīņåšč ęčēķč
  401. --[[
  402. if self.object.health - lasthealth > 0.001 or
  403. self.object.health - lasthealth < -0.001 then
  404. printf("%f | %f", self.object.health, self.object.health - lasthealth, game.time() - lasttime)
  405. lasthealth = self.object.health
  406. lasttime = game.time()
  407. end
  408. ]]
  409. -- Īįķīāėåķčå īņźėž÷åķč˙ āāīäą ń źėąāčąņóšū.
  410. if self.st.disable_input_time ~= nil and
  411. game.get_game_time():diffSec(self.st.disable_input_time) >= self.st.disable_input_idle
  412. then
  413. level.enable_input()
  414. self.st.disable_input_time = nil
  415. end
  416. --[[ -- this is not currently used even in sleep mod stuff
  417. -- Īįķīāėåķčå ńķą ń ļåšåķīńīģ ÷óāąźą ā óźąēąķķóž ļīēčöčž
  418. if self.st.sleep_relocate_time ~= nil and
  419. game.get_game_time():diffSec(self.st.sleep_relocate_time) >= self.st.sleep_relocate_idle
  420. then
  421. self.object:set_actor_position(self.st.sleep_relocate_point)
  422. local dir = self.st.sleep_relocate_point:sub(self.st.sleep_relocate_look)
  423. self.object:set_actor_direction(dir:getH())
  424. self.st.sleep_relocate_time = nil
  425. end
  426. --]]
  427.  
  428. -- Ąļäåéņ ļš˙ņąķčå īšóęč˙ čćšīźą āī āšåģ˙ äčąėīćą
  429. if weapon_hide == true or self.object:is_talking() then
  430. if self.weapon_hide == false then
  431. self.object:hide_weapon()
  432. self.weapon_hide = true
  433. end
  434. else
  435. if self.weapon_hide == true then
  436. self.object:restore_weapon()
  437. self.weapon_hide = false
  438. end
  439. end
  440.  
  441. -- īįķīāėåķčå šåńņščźņīšīā, źīņīšūå ļīä ėīćčźīé, ńšąįąņūāąåņ ÷åšåē čķņåšāąėū āšåģåķč
  442. if self.next_restrictors_update_time < time then
  443. bind_restrictor.actor_update(delta)
  444.  
  445. self.next_restrictors_update_time = time + 200
  446.  
  447. -- nv 100521 moved these here to reduce processing
  448. -- game_stats.update (delta, self.object) --used only for debugging
  449. self.actor_detector:update()
  450.  
  451. -- nv 070922 comment out for no auto-quests
  452. task_manager.actor_update()
  453.  
  454. if nv_debug then _z.show_coords(delta) end
  455. if nv_show_time then _z.show_time() end
  456. if nv_timer_pending then _dev.check_timer() end
  457.  
  458. -- nv130402 moved here to reduce loop load;
  459. -- checking five times a second is enough for a HUD message update
  460. --' Āūāīä ńīīįłåķč˙ ī įīėüųīé šąäčąöčč
  461. local rad_danger = "cs_radiation_danger"
  462. local hud = get_hud()
  463. local custom_static = hud:GetCustomStatic(rad_danger)
  464. if self.object.radiation >= 0.7 then
  465. if custom_static == nil then
  466. custom_static = hud:AddCustomStatic(rad_danger, true)
  467. custom_static:wnd():SetTextST("st_radiation_danger")
  468. end
  469. else
  470. if custom_static ~= nil then
  471. hud:RemoveCustomStatic(rad_danger)
  472. end
  473. end
  474. end
  475.  
  476. --[[ -- īįķīāėåķčå ļīńņļšīöåńńīā
  477. if post_process ~= 0 then
  478. if post_process:update () == true then
  479. post_process = 0
  480. end
  481. end
  482. --]]
  483.  
  484. -- īįķīāėåķčå ļńč-ąķņåķķū
  485. if sr_psy_antenna.psy_antenna then
  486. sr_psy_antenna.psy_antenna:update(delta)
  487. end
  488.  
  489. if nv_need_update then
  490. nv_need_update = false
  491. _z.do_update(self.object)
  492. end
  493.  
  494. if self.bCheckStart then
  495. -- level.hide_indicators() --enable this if you want no HUD at start (can still toggle in-game)
  496. -- printf("SET DEFAULT INFOS")
  497.  
  498. -- nv 100722 tweaked to better support free play
  499. if (level.name() == "l01_escape") then
  500. if not has_alife_info("storyline_actor_start") then
  501. self.object:give_info_portion("storyline_actor_start")
  502. -- _G.g_start_avi = true -- not used
  503. -- printf("*AVI* RUN START AVI")
  504. elseif not has_alife_info("zrp_free_play") then
  505. --has game start, might be in free play
  506. if has_alife_info("aes2_monolit_teleport_ready_final") then
  507. -- C-Con is dead
  508. self.object:give_info_portion("zrp_free_play")
  509. end
  510. end
  511. end
  512. if level_autosaves then manage_autosaves() end
  513. -- if not has_alife_info("encyclopedy") then
  514. -- self.object:give_info_portion("encyclopedy")
  515. -- end
  516.  
  517. if not has_alife_info("global_dialogs") then
  518. self.object:give_info_portion("global_dialogs")
  519. end
  520.  
  521. -- nv140331 not used
  522. -- if not has_alife_info("level_changer_icons") then
  523. -- self.object:give_info_portion("level_changer_icons")
  524. -- end
  525.  
  526. level_tasks.add_lchanger_location()
  527.  
  528. if use_sleeping_bag and abc_sleep then abc_sleep.add_bag_if_needed(true) end
  529. -- if zx then zx.fix_weather() end
  530.  
  531. self.bCheckStart = false
  532. end
  533.  
  534. if xrs_ai then xrs_ai.actor_update(delta) end
  535. if rx_ai then rx_ai.actor_update() end
  536. end
  537. ----------------------------------------------------------------------------------------------------------------------
  538. function actor_binder:save(packet)
  539.  
  540. local save_treasure_manager = true
  541.  
  542. -- printf("actor_binder:save(): self.object:name()='%s'", self.object:name())
  543. object_binder.save(self, packet)
  544.  
  545. --' Ńīõšąķ˙åģ óšīāåķü ńėīęķīńņč
  546. if save_treasure_manager == true then
  547. packet:w_u8(level.get_game_difficulty() + 128)
  548. else
  549. packet:w_u8(level.get_game_difficulty())
  550. end
  551.  
  552.  
  553. --' Ńīõšąķ˙åģ äąķķūå īį īņźėž÷åķķīģ āāīäå
  554. if self.st.disable_input_time == nil then
  555. packet:w_bool(false)
  556. else
  557. packet:w_bool(true)
  558. utils.w_CTime(packet, self.st.disable_input_time)
  559. -- enable following lines for your custom mod if needed; see load()
  560. -- -- 255 seconds of prohibiting action by player is more than plenty
  561. -- packet:w_u8(self.st.disable_input_idle)
  562. end
  563.  
  564. xr_logic.pstor_save_all(self.object, packet)
  565. self.weather_manager:save(packet)
  566.  
  567. sr_psy_antenna.save( packet )
  568.  
  569. if save_treasure_manager == true then
  570. treasure_manager.save(packet)
  571. end
  572.  
  573. task_manager.save(packet)
  574. self.actor_detector:save(packet)
  575. end
  576. ----------------------------------------------------------------------------------------------------------------------
  577. function show_load_error(reason)
  578. local corrupt_save_msg = "SAVE FILE IS CORRUPT - Load earlier save"
  579. if zrp_notice then zrp_notice.ShowMessage("\\n" .. corrupt_save_msg .. "\\n\\n" .. reason) end
  580. abort(corrupt_save_msg .. " - " .. reason) -- might exit, might not (default is "not")
  581. end
  582. ----------------------------------------------------------------------------------------------------------------------
  583. function actor_binder:load(reader)
  584. -- printf("actor_binder:load(): self.object:name()='%s'", self.object:name())
  585. object_binder.load(self, reader)
  586. -- printf("actor_binder:object_binder.load(): self.object:name()='%s'", self.object:name())
  587.  
  588. --' Ēąćšóęąåģ óšīāåķü ńėīęķīńņč
  589. local game_difficulty = reader:r_u8()
  590.  
  591. if game_difficulty == nil then
  592. -- nv - it's going to crash anyway; at least tell the player why
  593. show_load_error("Game difficulty is nil")
  594. return
  595. end
  596.  
  597. local load_treasure_manager = false
  598. if game_difficulty >= 128 then
  599. game_difficulty = game_difficulty - 128
  600. load_treasure_manager = true
  601. end
  602.  
  603. if game_difficulty < 0 or game_difficulty > 3 then
  604. -- nv - it's going to crash anyway; at least tell the player why
  605. show_load_error("Game difficulty should be 0-3, is " .. tostring(game_difficulty))
  606. return
  607. end
  608.  
  609. get_console():execute("g_game_difficulty "..game_difficulty_by_num[game_difficulty])
  610.  
  611. if reader:r_eof() then
  612. show_load_error("Unexpected end of save file encountered")
  613. return
  614. end
  615.  
  616. -- local stored_input_time = reader:r_u8() --bool per barin
  617. local stored_input_time = reader:r_bool()
  618. if stored_input_time == true then
  619. self.st.disable_input_time = utils.r_CTime(reader)
  620. -- disable next line, enable following for your custom mod if needed; see also save()
  621. self.st.disable_input_idle = xr_effects.punch_recovery_time -- prevent CTD
  622. -- self.st.disable_input_idle = reader:r_u8()
  623. end
  624.  
  625. xr_logic.pstor_load_all(self.object, reader)
  626. self.weather_manager:load(reader)
  627.  
  628. sr_psy_antenna.load(reader)
  629.  
  630. if load_treasure_manager == true then
  631. treasure_manager.load(reader)
  632. end
  633.  
  634.  
  635. task_manager.load(reader)
  636. self.actor_detector:load(reader)
  637. end
  638. ----------------------------------------------------------------------------------------------------------------------
  639.  
  640. --ńņąšņ ļšåōåņ÷ą ēāóźīā
  641. -- if string.find(command_line(), "-noprefetch") ~= nil then
  642. -- sound_prefetch.prefetch_sounds()
  643. -- end
  644.  
  645.  
  646. -- Weapon functions
  647. function hide_weapon()
  648. weapon_hide = true
  649. end
  650. function restore_weapon()
  651. weapon_hide = false
  652. end
  653.  
  654. if not _z then dbglog("No valid _z.script found") end
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement