xeniux

Untitled

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