xeniux

Untitled

Jul 5th, 2025
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.92 KB | None | 0 0
  1. local donation = require("donation_interactive")
  2.  
  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 sim = alife()
  12.  
  13. local game_difficulty_by_num = {
  14. [0] = "gd_novice",
  15. [1] = "gd_stalker",
  16. [2] = "gd_veteran",
  17. [3] = "gd_master"
  18. }
  19.  
  20. lasthealth = 0
  21. lasttime = 0
  22. post_process = 0
  23. local weapon_hide = false
  24. ----------------------------------------------------------------------------------------------------------------------
  25. class "actor_binder" (object_binder)
  26. ----------------------------------------------------------------------------------------------------------------------
  27. function actor_binder:__init (obj) super(obj)
  28. self.am = ogse_signals.get_mgr()
  29. self.am:call( "on_load_before_all" )
  30. self.am:call( "on_init", obj )
  31. self.bCheckStart = false
  32. self.weather_manager = level_weathers.WeatherManager()
  33. self.actor_detector = xr_detector.actor_detector()
  34. end
  35.  
  36. function actor_binder:__finalize()
  37. self.am:call( "on_finalize" )
  38. xr_s.init()
  39. end
  40. ----------------------------------------------------------------------------------------------------------------------
  41. function actor_binder:net_spawn(data)
  42. printf("actor net spawn")
  43.  
  44. level.show_indicators()
  45.  
  46. self.bCheckStart = true
  47. self.weapon_hide = false -- ???? ?? ?? ??? ?? ?????.
  48. weapon_hide = false -- ??????? ?????? ?????? ??.
  49.  
  50. if object_binder.net_spawn(self,data) == false then
  51. return false
  52. end
  53.  
  54. db.add_actor(self.object)
  55.  
  56. if self.st.disable_input_time == nil then
  57. level.enable_input()
  58. end
  59.  
  60. self.weather_manager:reset()
  61. -- game_stats.initialize ()
  62.  
  63. if(actor_stats.add_to_ranking~=nil)then
  64. actor_stats.add_to_ranking(self.object:id())
  65. end
  66.  
  67.  
  68.  
  69. --' ????? ????? ???
  70. death_manager.init_drop_settings()
  71.  
  72. self.am:call("on_spawn", data)
  73.  
  74. return true
  75. end
  76. ----------------------------------------------------------------------------------------------------------------------
  77. function actor_binder:net_destroy()
  78. if(actor_stats.remove_from_ranking~=nil)then
  79. actor_stats.remove_from_ranking(self.object:id())
  80. end
  81. -- game_stats.shutdown ()
  82. db.del_actor(self.object)
  83.  
  84. sr_light.clean_up ()
  85.  
  86. self.object:set_callback(callback.inventory_info, nil)
  87. self.object:set_callback(callback.article_info, nil)
  88. self.object:set_callback(callback.on_item_take, nil)
  89. self.object:set_callback(callback.on_item_drop, nil)
  90. --self.object:set_callback(callback.actor_sleep, nil)
  91. self.object:set_callback(callback.task_state, nil)
  92. self.object:set_callback(callback.level_border_enter, nil)
  93. self.object:set_callback(callback.level_border_exit, nil)
  94. self.object:set_callback(callback.take_item_from_box, nil)
  95.  
  96. self.object:set_callback( callback.on_before_use_item, nil )
  97. self.object:set_callback(callback.use_object, nil)
  98. self.object:set_callback(callback.on_belt, nil)
  99. self.object:set_callback( callback.on_ruck, nil )
  100. self.object:set_callback( callback.on_slot, nil )
  101.  
  102. self.object:set_callback( callback.on_key_press, nil )
  103. self.object:set_callback( callback.on_key_release, nil )
  104. self.object:set_callback( callback.on_key_hold, nil )
  105.  
  106. self.object:set_callback( callback.on_mouse_wheel, nil )
  107. self.object:set_callback( callback.on_mouse_move, nil )
  108. self.object:set_callback( callback.on_cell_item_focus, nil )
  109. self.object:set_callback( callback.on_cell_item_focus_lost, nil )
  110. self.object:set_callback( callback.on_cell_item_mouse, nil )
  111. self.object:set_callback(callback.hit, nil)
  112. self.object:set_callback(callback.entity_alive_before_hit, nil)
  113. self.object:set_callback(callback.on_actor_step, nil)
  114. self.object:set_callback(callback.death, nil)
  115. self.object:set_callback(callback.level_changer_action, nil)
  116. self.object:set_callback(callback.on_actor_quickknifehit, nil)
  117. self.object:set_callback(callback.on_actor_anim_pnv_on, nil)
  118.  
  119.  
  120. self.object:set_callback(callback.update_artefacts_on_belt, nil)
  121.  
  122. self.object:set_callback(callback.on_actor_firemode, nil)
  123. self.object:set_callback(callback.weapon_fired, nil)
  124.  
  125. self.object:set_callback(callback.on_actor_wpndraw, nil)
  126. self.object:set_callback(callback.on_actor_wpnholster, nil)
  127.  
  128. self.object:set_callback(callback.on_actor_jump, nil)
  129. self.object:set_callback(callback.on_actor_land, nil)
  130.  
  131. self.object:set_callback(callback.on_actor_weapon_zoom_in, nil)
  132. self.object:set_callback(callback.on_actor_weapon_zoom_out, nil)
  133. if sr_psy_antenna.psy_antenna then
  134. sr_psy_antenna.psy_antenna:destroy()
  135. sr_psy_antenna.psy_antenna = false
  136. end
  137.  
  138. xr_sound.stop_all_sound_object()
  139.  
  140. self.am:call("on_destroy")
  141.  
  142. object_binder.net_destroy(self)
  143. end
  144. ----------------------------------------------------------------------------------------------------------------------
  145. function actor_binder:reinit()
  146. object_binder.reinit(self)
  147.  
  148. local npc_id = self.object:id()
  149.  
  150. db.storage[npc_id] = { }
  151.  
  152. self.st = db.storage[npc_id]
  153. self.st.pstor = nil
  154.  
  155. self.next_restrictors_update_time = -10000
  156.  
  157. self.object:set_callback(callback.inventory_info, self.info_callback, self)
  158. self.object:set_callback(callback.article_info, self.article_callback, self)
  159. self.object:set_callback(callback.on_item_take, self.on_item_take, self)
  160. self.object:set_callback(callback.on_item_drop, self.on_item_drop, self)
  161. self.object:set_callback(callback.trade_sell_buy_item, self.on_trade, self) -- for game stats
  162. self.object:set_callback(callback.task_state, self.task_callback, self)
  163. self.object:set_callback(callback.level_border_enter, self.level_border_enter, self)
  164. self.object:set_callback(callback.level_border_exit, self.level_border_exit, self)
  165. self.object:set_callback(callback.take_item_from_box, self.take_item_from_box, self)
  166. self.object:set_callback(callback.use_object, self.use_object, self)
  167. self.object:set_callback( callback.on_before_use_item, self.before_use, self )
  168. self.object:set_callback(callback.on_belt, self.item_to_belt, self)
  169. self.object:set_callback( callback.on_ruck, self.item_to_backpack, self )
  170.  
  171. self.object:set_callback( callback.on_slot, self.item_to_slot, self )
  172. self.object:set_callback( callback.on_key_press, self.on_key, self )
  173. self.object:set_callback( callback.on_key_release, self.on_key_free, self )
  174. self.object:set_callback( callback.on_key_hold, self.on_key_hold, self )
  175.  
  176.  
  177. self.object:set_callback( callback.on_mouse_wheel, self.on_wheel_rotation, self )
  178. self.object:set_callback( callback.on_mouse_move, self.on_mouse_move, self )
  179. self.object:set_callback( callback.on_cell_item_focus, self.on_cell_item_focus, self )
  180. self.object:set_callback( callback.on_cell_item_focus_lost, self.on_cell_item_focus_lost, self )
  181. self.object:set_callback( callback.on_cell_item_mouse, self.on_cell_item_mouse, self )
  182.  
  183. self.object:set_callback(callback.hit, self.actor_hit_callback, self)
  184. self.object:set_callback(callback.entity_alive_before_hit, self.before_hit_callback, self)
  185. self.object:set_callback(callback.death, self.actor_death_callback, self)
  186. self.object:set_callback(callback.on_actor_step, self.on_actor_step_callback, self)
  187. self.object:set_callback(callback.level_changer_action, self.level_changer_action, self)
  188.  
  189. self.object:set_callback( callback.on_actor_quickknifehit, self.quickknifehit, self )
  190. self.object:set_callback( callback.on_actor_anim_pnv_on, self.actor_anim_pnv_on, self )
  191.  
  192. self.object:set_callback( callback.on_actor_firemode, self.on_actor_firemode_change, self )
  193.  
  194. self.object:set_callback(callback.update_artefacts_on_belt, self.update_artefacts_on_belt, self)
  195.  
  196. self.object:set_callback(callback.weapon_fired, self.on_weapon_fired, self)
  197. self.object:set_callback(callback.on_actor_wpndraw, self.actor_wpndraw, self)
  198. self.object:set_callback(callback.on_actor_wpnholster, self.actor_wpnholster, self)
  199.  
  200. self.object:set_callback(callback.on_actor_jump, self.actor_jump, self)
  201. self.object:set_callback(callback.on_actor_land, self.actor_land, self)
  202.  
  203. self.object:set_callback(callback.on_actor_weapon_zoom_in, self.on_actor_weapon_zoom_in, self)
  204. self.object:set_callback(callback.on_actor_weapon_zoom_out, self.on_actor_weapon_zoom_out, self)
  205.  
  206. self.am:call("on_reinit")
  207.  
  208. end
  209.  
  210. function actor_binder:actor_jump()
  211. end
  212.  
  213. function actor_binder:actor_land()
  214. local rand = math.random(1,2)
  215. level.add_cam_effector("camera_effects\\landing_crp" .. rand .. ".anm", 1905, false, "")
  216. local land_snd = xr_sound.get_safe_sound_object("actor\\jump_sounds\\land_default")
  217. land_snd:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 0.6)
  218. end
  219.  
  220. local snd_using
  221. function actor_binder:actor_wpndraw()
  222. dsh.timeout( 100, function()
  223. local act_it = db.actor:active_item()
  224. if act_it then
  225. local snd2 = get_string( act_it:section(), "snd_draw" )
  226. snd_using = sound_object(snd2)
  227. if not snd_using:playing() then
  228. snd_using:play( db.actor, 0, sound_object.s2d )
  229. end
  230. end
  231. end )
  232. end
  233.  
  234. function actor_binder:actor_wpnholster()
  235. dsh.timeout( 100, function()
  236. local act_it = db.actor:active_item()
  237. if act_it then
  238. local snd2 = get_string( act_it:section(), "snd_holster" )
  239. snd_using = sound_object(snd2)
  240. if not snd_using:playing() then
  241. snd_using:play( db.actor, 0, sound_object.s2d )
  242. end
  243. end
  244. end )
  245. end
  246.  
  247. function actor_binder:before_hit_callback(hit_data)
  248.  
  249. self.am:call("on_actor_before_hit", hit_data)
  250.  
  251. local obj = hit_data.who
  252. if obj then
  253. local hit_type = hit_data.hit_type
  254. if hit_type == hit.telepatic then
  255. if hit_data.who_id == db.actor:id() then
  256. local cdir = device().cam_dir
  257. local angle_down = cdir.y
  258. log1(angle_down)
  259. if angle_down <= -0.95 or angle_down >= 0.95 then
  260. return
  261. else
  262. local flash_snd = xr_sound.get_safe_sound_object([[weapons\zarya2_flash]])
  263. flash_snd:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
  264. level.add_pp_effector ("teleport.ppe", 2009, false)
  265. end
  266. end
  267. elseif hit_type == hit.burn then
  268. if db.actor:dont_has_info( "actor_burning" ) then
  269. db.actor:give_info_portion("actor_burning")
  270. end
  271. end
  272. end
  273.  
  274. end
  275.  
  276. function actor_binder:on_actor_firemode_change( obj )
  277. local act_it = db.actor:active_item()
  278. if act_it and db.actor:zoom_mode() then
  279. local firemode = get_float( act_it:section(), "firemod_status" )
  280. if firemode and firemode == 1 then
  281. anm_name2 = "camera_effects\\weapon\\l85_gloff_firemode_a_to_1.anm"
  282. game.play_hud_anm(anm_name2, 2, 1, 1, false)
  283. level.add_cam_effector("camera_effects\\weapon\\l85_gloff_firemode_a_to_1.anm", 1902, false, "")
  284. end
  285. end
  286. end
  287.  
  288. function actor_binder:on_weapon_fired()
  289. ogse_body_states.on_weapon_fired()
  290. ogse_body_states.actor_on_weapon_fire()
  291. end
  292.  
  293. function actor_binder:update_artefacts_on_belt(dt)
  294. self.am:call("update_artefacts_on_belt", dt)
  295. end
  296.  
  297. function actor_binder:quickknifehit( obj )
  298. start_real_timer("kick_hit", 150, "gunsl_hud_animations_mgr.get_hud_animations_mgr():kick_hit_melee")
  299. end
  300.  
  301. function actor_binder:actor_anim_pnv_on( obj )
  302. start_real_timer("on_off_pnv", 400, "ogse_night_vision.on_off_pnv")
  303. local snd_nv = sound_object('weapons\\nv_deact')
  304. snd_nv:play(db.actor, 0, sound_object.s2d)
  305. end
  306.  
  307. function actor_binder:on_actor_step_callback( obj, material, power )
  308. ogse_body_states.actor_on_exo_footstep(obj, material, power)
  309.  
  310. end
  311.  
  312. function actor_binder:actor_death_callback(victim, who)
  313. gunsl_3dscopes_backlight.on_zoom_out_night()
  314. local hud = get_hud()
  315. if hud:GetCustomStatic("gunsl_nv_screen_mask")~=nil then
  316. hud:RemoveCustomStatic("gunsl_nv_screen_mask")
  317. end
  318. level.add_cam_effector("camera_effects\\surge_02.anm", 2532, false, "")
  319. level.add_pp_effector("surge_fade.ppe", 2011, true)
  320. start_real_timer("death_wake", 1300, "bind_stalker.death_wake")
  321. level.disable_input()
  322. end
  323.  
  324. function death_wake()
  325. level.add_pp_effector("deadcity_wake.ppe", 4467, true)
  326. end
  327.  
  328. function actor_binder:on_wheel_rotation( vol )
  329. xr_s.on_event("mouse_wheel", vol)
  330. end
  331.  
  332. function actor_binder:on_mouse_move( velx, vely )
  333. end
  334.  
  335. function actor_binder:on_cell_item_focus( obj )
  336. xr_s.on_event("cell_item_focus", obj)
  337. gunsl_drag_drop.on_cell_item_focus( obj )
  338. end
  339.  
  340.  
  341. function actor_binder:on_cell_item_focus_lost( obj )
  342. xr_s.on_event("cell_item_focus_lost", obj)
  343. gunsl_drag_drop.on_cell_item_focus_lost( obj )
  344. end
  345.  
  346.  
  347. function actor_binder:on_cell_item_mouse( obj, x, y, action )
  348. gunsl_drag_drop.on_cell_item_mouse( obj, x, y, action )
  349. end
  350.  
  351. function actor_binder:level_changer_action( obj, wnd )
  352. local sobj = obj:get_alife_object()
  353. local lc = sobj:get_level_changer()
  354. local dest_vertex = lc.dest_game_vertex_id
  355. local dest_lname = alife():level_name(
  356. game_graph():vertex( dest_vertex ):level_id()
  357. )
  358. if db.actor:has_info( "ui_inventory" ) then
  359. level.start_stop_menu( level.main_input_receiver(), true )
  360. end
  361.  
  362. local msg_text_wnd = wnd:FindChild( "message_box_change_level:button_yes" )
  363. if db.actor:has_info( "anim_action" ) then
  364. level.only_allow_movekeys(false)
  365. msg_text_wnd:GetCUIStatic():SetWndRect( Frect():set( -1000, 365, 117, 29 ) )
  366. else
  367. msg_text_wnd:GetCUIStatic():SetWndRect( Frect():set( 250, 154, 367, 183 ) )
  368. end
  369. end
  370.  
  371. function actor_binder:actor_hit_callback(obj, amount, local_direction, who, bone_index)
  372.  
  373. if who and who:id()~=db.actor:id() and amount > 0 then
  374. ogse_critical_hit.check_critical(amount, bone_index, who)
  375. ogse_critical_hit.helmet_damage(amount, bone_index, who)
  376. if IsMonster(who) then
  377. local mob_id = class_id or get_clsid (who)
  378. if ( mob_id == clsid.boar_s) or ( mob_id == clsid.chimera_s) or ( mob_id == clsid.bloodsucker_s) or ( mob_id == clsid.snork_s) then
  379. if amount > 0.20 then
  380. if db.actor:see(who) then
  381. bind_monster.boar_strike()
  382. end
  383. end
  384. end
  385. end
  386. if IsAnomaly(who) then
  387. local sect = who:section()
  388. if string.find(sect, "zharka") then
  389. if db.actor:dont_has_info( "actor_burning" ) then
  390. db.actor:give_info_portion("actor_burning")
  391. end
  392. end
  393. end
  394. end
  395.  
  396. end
  397. ----------------------------------------------------------------------------------------------------------------------
  398. function actor_binder:on_actor_weapon_zoom_in( obj )
  399.  
  400. local wpni = db.actor:active_item()
  401. if wpni then
  402. if ogse_wpn_utils.get_zoom_anm_status( wpni ) == 1 then
  403. local anm_name = "aim_in.anm"
  404. game.play_hud_anm(anm_name, 2, 1.0, 1, false)
  405. local snd = get_string(wpni:section(), "snd_aim_start")
  406. local snd_obj = sound_object(snd)
  407. if not snd_obj:playing() then
  408. snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 0.3)
  409. end
  410.  
  411.  
  412. end
  413. end
  414.  
  415.  
  416.  
  417.  
  418. if not get_console():get_bool("g_3d_scopes") then
  419. if db.actor:active_item():get_weapon():UseScopeTexture() then
  420. gunsl_hud_indicators.remove_indiks()
  421. ogse_quick_slots.RemoveFastUseSlotsHud()
  422. end
  423. end
  424. end
  425.  
  426. function actor_binder:on_actor_weapon_zoom_out( obj )
  427.  
  428.  
  429. local wpni = db.actor:active_item()
  430. if wpni then
  431. if ogse_wpn_utils.get_zoom_anm_status( wpni ) == 1 then
  432. local anm_name = "aim_out.anm"
  433. game.play_hud_anm(anm_name, 2, 1.0, 1, false)
  434. local snd = get_string(wpni:section(), "snd_aim_end")
  435. local snd_obj = sound_object(snd)
  436. if not snd_obj:playing() then
  437. snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 0.3)
  438. end
  439. end
  440. end
  441.  
  442.  
  443. if not get_console():get_bool("g_3d_scopes") then
  444. if db.actor:active_item():get_weapon():UseScopeTexture() then
  445. gunsl_hud_indicators.show_indicators()
  446. ogse_quick_slots.FastUseSlotsHud()
  447. end
  448. end
  449. end
  450.  
  451.  
  452. local keyboard_events = {
  453. [ "on_key_down" ] = "on_key_down",
  454. [ "on_key_hold" ] = "on_key_hold",
  455. [ "on_key_up" ] = "on_key_up",
  456. }
  457.  
  458. local kShifts = { [DIK_keys.DIK_RSHIFT] = true, [DIK_keys.DIK_LSHIFT] = true }
  459.  
  460. function actor_binder:on_key(key, bind)
  461. self.am:call("on_key_down", key, bind)
  462.  
  463. xr_s.on_event( "key_press", key, bind )
  464. gunsl_hud_animations_mgr.get_hud_animations_mgr():on_keyboard(key, bind)
  465.  
  466. end
  467.  
  468. function actor_binder:on_key_free(key, bind)
  469. self.am:call("on_key_up", key, bind)
  470. end
  471.  
  472. function actor_binder:on_key_hold(key, bind)
  473. end
  474.  
  475.  
  476.  
  477. function actor_binder:take_item_from_box(box, item)
  478. local story_id = box:story_id()
  479. if story_id == nil then
  480. return
  481. end
  482.  
  483. treasure_manager.take_item_from_box(box, story_id)
  484. --[[
  485. local respawner = se_respawn.get_respawner_by_parent(story_id)
  486. if respawner == nil then
  487. return
  488. end
  489.  
  490. --' ?????? ?????? ???? ? ?????
  491. respawner:remove_spawned(item:id())
  492.  
  493. local smart_terrain = db.strn_by_respawn[respawner:name()]
  494. if smart_terrain == nil then
  495. return
  496. end
  497.  
  498. local npc = smart_terrain.gulag:get_nearest_online_obj(db.actor:position())
  499. if npc ~= nil then
  500. xr_sound.set_sound_play(npc, "reac_box")
  501. xr_gulag.setGulagEnemy(smart_terrain:name() , db.actor)
  502. end
  503. ]]
  504. end
  505. ----------------------------------------------------------------------------------------------------------------------
  506.  
  507.  
  508. function actor_binder:before_use( item )
  509. if not item then return end
  510. local sobj = alife():object(item:id())
  511. if not sobj then return end
  512.  
  513. self.am:call("on_actor_before_use", item, sobj)
  514.  
  515. end
  516.  
  517.  
  518. function actor_binder:item_to_belt(obj)
  519. if not obj then return end
  520. local sobj = alife():object(obj:id())
  521. if not sobj then return end
  522.  
  523. self.am:call("on_item_to_belt", obj, sobj)
  524.  
  525. end
  526.  
  527. ----------------------------------------------------------------------------------------------------------------------
  528. function actor_binder:item_to_backpack( obj )
  529.  
  530. local sobj = sim:object( obj:id() )
  531. if sobj then
  532. -- ??? ???, ??? ???? ? ????? ????, ? ??? ?? ?? ?
  533. -- ???? ?? ???? ? ???
  534.  
  535. self.am:call("on_item_to_ruck", obj, sobj)
  536.  
  537. end
  538. end
  539. ----------------------------------------------------------------------------------------------------------------------
  540.  
  541. function actor_binder:item_to_slot( obj )
  542. local sobj = sim:object( obj:id() )
  543. if sobj then
  544.  
  545. self.am:call("on_item_to_slot", obj, sobj)
  546.  
  547. end
  548. end
  549. local anim_plays = false
  550. ----------------------------------------------------------------------------------------------------------------------
  551. function actor_binder:on_item_take (obj)
  552. self.am:call("on_take", obj, sobj)
  553.  
  554. if db.actor:has_info( "ui_car_body" ) then
  555. if not anim_plays then
  556. local pickup_anm_sec = "anim_pickup"
  557. local anm_name = "script\\gasmask.anm"
  558. local pickup_anm_time = game.play_hud_motion(1, pickup_anm_sec, "anm_take", true, 1.4)
  559. game.play_hud_anm(anm_name, 0, 0.5, 1, false)
  560. dsh.timeout( pickup_anm_time - 100, function()
  561. anim_plays = nil
  562. end )
  563. dsh.timeout( pickup_anm_time - 300, function()
  564. ogse_body_states.play_pickup_snd(obj)
  565. end )
  566. anim_plays = true
  567. end
  568. end
  569.  
  570. level_tasks.proceed(self.object)
  571. xr_statistic.addArtefact(obj)
  572. --game_stats.update_take_item (obj, self.object)
  573.  
  574. end
  575. ----------------------------------------------------------------------------------------------------------------------
  576. function actor_binder:on_item_drop (obj)
  577. level_tasks.proceed(self.object)
  578.  
  579. self.am:call("on_drop", obj, sobj)
  580.  
  581. if string.find( obj:name(), "silencer" ) then
  582. ogse.check_pistol_slot()
  583. end
  584.  
  585. --game_stats.update_drop_item (obj, self.object)
  586.  
  587. end
  588. ----------------------------------------------------------------------------------------------------------------------
  589.  
  590. function actor_binder:level_border_enter(npc, info_id)
  591. self.actor_detector:actor_enter()
  592. end
  593. ----------------------------------------------------------------------------------------------------------------------
  594. function actor_binder:level_border_exit(npc, info_id)
  595. self.actor_detector:actor_exit()
  596. end
  597. ----------------------------------------------------------------------------------------------------------------------
  598. function actor_binder:info_callback(npc, info_id)
  599.  
  600. self.am:call("on_info", info_id)
  601.  
  602. if info_id=="ui_inventory" then
  603. -- gunsl_items_anims.save_bind()
  604. gunsl_ui_inv_add.inventory_open()
  605. gunsl_ui_inv_add.poloski_update()
  606. gunsl_drag_drop.on_show_inventory()
  607. elseif info_id=="ui_inventory_hide" then
  608. gunsl_ui_inv_add.inventory_close()
  609. gunsl_drag_drop.on_hide_inventory()
  610. ogse_quick_slots.clear_quick_slot_idik()
  611. end
  612.  
  613. if info_id=="ui_pda" then
  614. ogse_body_states.pda_off()
  615. gunsl_items_anims.hide_scaner_scr()
  616. elseif info_id=="ui_pda_hide" then
  617. gunsl_items_anims.restore_scaner_scr()
  618. ogse_body_states.pda_on()
  619. end
  620.  
  621. if info_id=="ui_trade" then
  622. gunsl_ui_inv_add.trade_open()
  623. elseif info_id=="ui_trade_hide" then
  624. gunsl_ui_inv_add.trade_close()
  625. end
  626.  
  627. if info_id=="ui_car_body" then
  628. gunsl_ui_inv_add.body_open()
  629. elseif info_id=="ui_car_body_hide" then
  630. gunsl_ui_inv_add.body_close()
  631. end
  632.  
  633. if info_id == "cit_jail_doctor_pryp_task" then
  634. ogse.actor_change_name()
  635. end
  636.  
  637. printf("*INFO*: npc='%s' id='%s'", npc:name(), info_id)
  638. --' ???
  639. level_tasks.proceed(self.object)
  640. -- ???? ? ???
  641. level_tasks.process_info_portion(info_id)
  642. gunsl_upgrade.show_hide_menu(info_id)
  643. end
  644. ----------------------------------------------------------------------------------------------------------------------
  645. function actor_binder:on_trade (item, sell_bye, money)
  646. if sell_bye == true then
  647. game_stats.money_trade_update (money)
  648. else
  649. game_stats.money_trade_update (-money)
  650. end
  651. end
  652. ----------------------------------------------------------------------------------------------------------------------
  653. function actor_binder:article_callback(npc, group, name)
  654. --printf("article_callback [%s][%s]", group, name)
  655. if device().precache_frame >1 then return end
  656.  
  657. if group == "Diary" then
  658. news_manager.send_encyclopedy("diary", group)
  659. else
  660. news_manager.send_encyclopedy("encyclopedy", group)
  661. end
  662. end
  663. ----------------------------------------------------------------------------------------------------------------------
  664.  
  665. function actor_binder:task_callback(_task, _objective, _state)
  666. task_manager.task_callback(_task:get_id(), _objective:get_idx(), _state)
  667. if _objective:get_idx() == 0 then
  668. if _state == task.fail then
  669. news_manager.send_task(db.actor, "fail", _task, _objective)
  670. elseif _state == task.skipped then
  671. news_manager.send_task(db.actor, "skipped", _task, _objective)
  672. elseif _state == task.completed then
  673. task_manager.reward_by_task(_task)
  674. news_manager.send_task(db.actor, "complete", _task, _objective)
  675. else
  676. news_manager.send_task(db.actor, "new", _task, _objective)
  677. end
  678. else
  679. if _task:get_objective(0):get_state() == task.in_progress then
  680. news_manager.send_task(db.actor, "update", _task, _objective)
  681. end
  682. end
  683. end
  684.  
  685. ----------------------------------------------------------------------------------------------------------------------
  686. function actor_binder:map_location_added_callback(spot_type_str, object_id)
  687. if (false==app_ready()) or (device().precache_frame>1) then return end
  688. --'news_manager.send_task(db.actor, "new")
  689. end
  690. ----------------------------------------------------------------------------------------------------------------------
  691.  
  692.  
  693. function actor_binder:update(delta)
  694. donation = donation or require("donation_interactive")
  695. donation.Update(delta)
  696.  
  697.  
  698. object_binder.update(self, delta)
  699.  
  700. self.am:call("on_update", delta)
  701.  
  702.  
  703. xr_s.on_update( delta )
  704.  
  705.  
  706. local time = time_global()
  707.  
  708. if not first_update then
  709.  
  710. self.am:call("on_first_update")
  711.  
  712. first_update = true
  713. end
  714.  
  715.  
  716. if get_console():get_bool("hud_draw") then
  717. if (not db.actor:zoom_mode()) then
  718. ogse_quick_slots.FastUseSlotsHud()
  719. gunsl_hud_indicators.show_indicators()
  720. end
  721.  
  722. else
  723. ogse_quick_slots.RemoveFastUseSlotsHud()
  724. gunsl_hud_indicators.remove_indiks()
  725. end
  726.  
  727. gunsl_hud_animations_mgr.get_hud_animations_mgr():update()
  728.  
  729.  
  730. sleep_manager.hp_corrector()
  731.  
  732.  
  733. game_stats.update (delta, self.object)
  734.  
  735. -- ??? ???
  736. self.weather_manager:update()
  737.  
  738. -- ??? ??? ?????
  739. self.actor_detector:update()
  740.  
  741. -- ??? ???? ??? ???
  742. xr_sound.update_actor()
  743.  
  744.  
  745. -- ????? ?????? ??? ? ?????.
  746. if self.st.disable_input_time ~= nil and
  747. game.get_game_time():diffSec(self.st.disable_input_time) >= self.st.disable_input_idle
  748. then
  749. level.enable_input()
  750. self.st.disable_input_time = nil
  751. end
  752. -- ????? ?? ? ????? ???? ? ????? ????
  753. if self.st.sleep_relocate_time ~= nil and
  754. game.get_game_time():diffSec(self.st.sleep_relocate_time) >= self.st.sleep_relocate_idle
  755. then
  756. self.object:set_actor_position(self.st.sleep_relocate_point)
  757. local dir = self.st.sleep_relocate_point:sub(self.st.sleep_relocate_look)
  758. self.object:set_actor_direction(dir:getH())
  759. self.st.sleep_relocate_time = nil
  760. end
  761.  
  762. -- ???? ????? ??? ??? ? ??? ????
  763. if weapon_hide == true or self.object:is_talking() then
  764. if self.weapon_hide == false then
  765. self.object:hide_weapon()
  766. self.weapon_hide = true
  767. end
  768. else
  769. if self.weapon_hide == true then
  770. self.object:restore_weapon()
  771. self.weapon_hide = false
  772. end
  773. end
  774.  
  775. -- ????? ??????, ???? ?? ????, ?????? ??? ????? ????
  776. if self.next_restrictors_update_time < time then
  777. bind_restrictor.actor_update(delta)
  778.  
  779. self.next_restrictors_update_time = time + 200
  780.  
  781. task_manager.actor_update()
  782. end
  783.  
  784. -- ????? ???????
  785. if post_process ~= 0 then
  786. if post_process:update () == true then
  787. post_process = 0
  788. end
  789. end
  790.  
  791. -- ????? ??-????
  792. if sr_psy_antenna.psy_antenna then
  793. sr_psy_antenna.psy_antenna:update(delta)
  794. end
  795.  
  796. --' ??? ????? ? ???? ????
  797. if self.object.radiation >= 0.7 then
  798. local hud = get_hud()
  799. local custom_static = hud:GetCustomStatic("cs_radiation_danger")
  800. if custom_static == nil then
  801. hud:AddCustomStatic("cs_radiation_danger", true)
  802. hud:GetCustomStatic("cs_radiation_danger"):wnd():SetTextST("st_radiation_danger")
  803. end
  804. else
  805. local hud = get_hud()
  806. local custom_static = hud:GetCustomStatic("cs_radiation_danger")
  807. if custom_static ~= nil then
  808. hud:RemoveCustomStatic("cs_radiation_danger")
  809. end
  810. end
  811.  
  812.  
  813.  
  814. if self.bCheckStart then
  815. printf("SET DEFAULT INFOS")
  816.  
  817. if not has_alife_info("storyline_actor_start") and
  818. (level.name() == "l01_escape")
  819. then
  820. self.object:give_info_portion("storyline_actor_start")
  821. _G.g_start_avi = true
  822. printf("*AVI* RUN START AVI")
  823. art_mgr.del_xlam()
  824. ogse.monster_first_run()
  825. end
  826.  
  827. -- if not has_alife_info("encyclopedy") then
  828. -- self.object:give_info_portion("encyclopedy")
  829. -- end
  830.  
  831. if not has_alife_info("global_dialogs") then
  832. self.object:give_info_portion("global_dialogs")
  833. end
  834.  
  835. if not has_alife_info("level_changer_icons") then
  836. self.object:give_info_portion("level_changer_icons")
  837. end
  838.  
  839. level_tasks.add_lchanger_location()
  840.  
  841. self.bCheckStart = false
  842. end
  843. art_mgr.update()
  844. -- naxac +
  845. save_rename.update(time)
  846. -- naxac -
  847. end
  848. ----------------------------------------------------------------------------------------------------------------------
  849. function actor_binder:save(packet)
  850.  
  851. local save_treasure_manager = true
  852.  
  853. printf("actor_binder:save(): self.object:name()='%s'", self.object:name())
  854. object_binder.save(self, packet)
  855.  
  856. --' ????? ???? ?????
  857. if save_treasure_manager == true then
  858. packet:w_u8(level.get_game_difficulty() + 128)
  859. else
  860. packet:w_u8(level.get_game_difficulty())
  861. end
  862.  
  863.  
  864. --' ????? ???? ? ??????? ???
  865. if self.st.disable_input_time == nil then
  866. packet:w_bool(false)
  867. else
  868. packet:w_bool(true)
  869. utils.w_CTime(packet, self.st.disable_input_time)
  870. end
  871.  
  872. xr_logic.pstor_save_all(self.object, packet)
  873. self.weather_manager:save(packet)
  874.  
  875. sr_psy_antenna.save( packet )
  876.  
  877. if save_treasure_manager == true then
  878. treasure_manager.save(packet)
  879. end
  880.  
  881. self.am:call("on_save", packet)
  882.  
  883. task_manager.save(packet)
  884. xr_statistic.save(packet)
  885. self.actor_detector:save(packet)
  886. art_mgr.save(packet)
  887. save_rename.on_save()
  888. end
  889. ----------------------------------------------------------------------------------------------------------------------
  890. function actor_binder:load(reader)
  891. printf("actor_binder:load(): self.object:name()='%s'", self.object:name())
  892. object_binder.load(self, reader)
  893. printf("actor_binder:object_binder.load(): self.object:name()='%s'", self.object:name())
  894.  
  895. --' ????? ???? ?????
  896. local game_difficulty = reader:r_u8()
  897.  
  898. local load_treasure_manager = false
  899. if game_difficulty >= 128 then
  900. game_difficulty = game_difficulty - 128
  901. load_treasure_manager = true
  902. end
  903.  
  904.  
  905. get_console():execute("g_game_difficulty "..game_difficulty_by_num[game_difficulty])
  906.  
  907. if reader:r_eof() then
  908. abort("SAVE FILE IS CORRUPT")
  909. end
  910.  
  911. local stored_input_time = reader:r_u8()
  912. if stored_input_time == true then
  913. self.st.disable_input_time = utils.r_CTime(reader)
  914. end
  915.  
  916. xr_logic.pstor_load_all(self.object, reader)
  917. self.weather_manager:load(reader)
  918.  
  919. sr_psy_antenna.load(reader)
  920.  
  921. if load_treasure_manager == true then
  922. treasure_manager.load(reader)
  923. end
  924.  
  925. self.am:call("on_load", reader)
  926.  
  927. task_manager.load(reader)
  928. xr_statistic.load(reader)
  929. self.actor_detector:load(reader)
  930. art_mgr.load(reader)
  931. ogsm_freeplay.mark_lc()
  932.  
  933.  
  934. end
  935. ----------------------------------------------------------------------------------------------------------------------
  936.  
  937. --??? ????? ???
  938. --if string.find(command_line(), "-noprefetch") == nil then
  939. -- sound_prefetch.prefetch_sounds()
  940. --end
  941.  
  942.  
  943. -- Weapon functions
  944. function hide_weapon()
  945. weapon_hide = true
  946. end
  947. function restore_weapon()
  948. weapon_hide = false
  949. end
  950.  
  951. // this is test for section iteration
  952. /**
  953. local function test_section_iteration(file_name, section_name)
  954. printf ("file : %s",file_name)
  955. printf ("section : %s",section_name)
  956.  
  957. local file = ini_file(file_name)
  958. local n = file:line_count(section_name)
  959. printf ("lines : %d",n)
  960.  
  961. local id, value = "", "", result
  962. for i=0,n-1 do
  963. result, id, value = file:r_line(section_name,i,"","")
  964. printf ("line %d : %s = %s",i,id,value)
  965. end
  966. end
  967.  
  968. test_section_iteration("system.ltx","space_restrictor")
  969. /**/
  970.  
  971.  
  972.  
Advertisement
Add Comment
Please, Sign In to add comment