Advertisement
Guest User

Untitled

a guest
May 30th, 2021
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.42 KB | None | 0 0
  1. --[[
  2.     Tronex
  3.     2020/3/10
  4.     Artefact binder
  5.    
  6.     Inventory radiation:
  7.         Non-contained radioactive artefacts in ruck will irrediate the actor by half of their rad speed value
  8.         This is a Misery feature, reworked and moved to this script
  9.        
  10.     Belt HUD:
  11.         Show icons of belt artefacts on main HUD
  12.         This is a CoC feature, reworked and moved to this script
  13.        
  14.     Port of lattest CoC version, fixed by xQd and Alundaio
  15. --]]
  16.  
  17. local rad_factor = 0.5 -- multiplier to artefact rad effect in ruck
  18. local rad_tg_step = 300 --[ms]
  19. local dgr_tg_step = 2000 --[ms]
  20. local belted_arts = {}
  21. local imm_mul, mul, _tmr
  22. artefact_degradation_feature = false
  23. backpack_degradation_feature = false
  24. art_weight_add = 0
  25. local in_actor_ruck = utils_item.in_actor_ruck
  26.  
  27. function utils_item.is_degradable(obj, sec)
  28.     local section = obj and obj:section() or sec
  29.     return section and ((ini_sys:r_bool_ex(section,"use_condition") and (not IsItem("multiuse",section))) or (ini_sys:r_string_ex(section,"kind") == "i_arty" )or (ini_sys:r_string_ex(section,"kind") == "i_arty_cont" ))
  30. end
  31.  
  32. local function main_loop()
  33.     local tg = time_global()
  34.     if (_tmr and tg < _tmr) then
  35.         return false
  36.     end
  37.     _tmr = tg + 2000    -- if you change this value timed artefact multipliers will need changes
  38.  
  39.     if not (db.actor) then
  40.         return false
  41.     end
  42.  
  43.     local actor = db.actor
  44.     local tot_weight = actor:get_total_weight()
  45.     local max_weight = actor:get_actor_max_walk_weight()
  46.    
  47.     local outfit = actor:item_in_slot(7)
  48.     local backpack = actor:item_in_slot(13)
  49.     max_weight = max_weight + (outfit and outfit:get_additional_max_weight() or 0)
  50.     max_weight = max_weight + (backpack and backpack:get_additional_max_weight() or 0)
  51.     actor:iterate_belt( function(owner, obj)
  52.       local c_arty = obj:cast_Artefact()
  53.       max_weight = max_weight + (c_arty and c_arty:AdditionalInventoryWeight() or 0)
  54.     end)
  55.  
  56.     art_weight_add = 0
  57.     local cond_loss, val = 0, 0
  58.     for art_id,active in pairs(belted_arts) do
  59.         if (active) then
  60.             local arte = level.object_by_id(art_id)
  61.             if not (arte and db.actor:is_on_belt(arte)) then
  62.                 belted_arts[art_id] = nil
  63.             else
  64.                 cond_loss = 0
  65.                 if (db.actor.health < 1.0) then
  66.                     val = ini_sys:r_float_ex(arte:section(),"health_restore_speed") or 0
  67.                     if (val > 0) then
  68.                        cond_loss = cond_loss + (val * mul["health"])
  69.                     end
  70.                 end
  71.                 if (db.actor.radiation > 0) then
  72.                     val = ini_sys:r_float_ex(arte:section(),"radiation_restore_speed") or 0
  73.                     if (val < 0) then
  74.                         cond_loss = cond_loss + (math.abs(val) * mul["radiation"])
  75.                     end
  76.                 end
  77.                 if (db.actor.satiety < 1.0) then
  78.                     val = ini_sys:r_float_ex(arte:section(),"satiety_restore_speed") or 0
  79.                     if (val > 0) then
  80.                         cond_loss = cond_loss + (val * mul["satiety"])
  81.                     end    
  82.                 end
  83.                 if (db.actor.power < 1.0) then
  84.                     val = ini_sys:r_float_ex(arte:section(),"power_restore_speed") or 0
  85.                     if (val > 0) then
  86.                         cond_loss = cond_loss + (val * mul["power"])
  87.                     end
  88.                 end
  89.                if (db.actor.bleeding > 0) then
  90.                     val = ini_sys:r_float_ex(arte:section(),"bleeding_restore_speed") or 0
  91.                     if (val > 0) then
  92.                         cond_loss = cond_loss + (val * mul["bleeding"])
  93.                     end
  94.                end
  95.                 if (db.actor.psy_health < 1.0) then
  96.                     val = ini_sys:r_float_ex(arte:section(),"psy_health_restore_speed") or 0
  97.                     if (val > 0) then
  98.                         cond_loss = cond_loss + (val * mul["psy_health"])
  99.                     end
  100.                 end
  101.            
  102.                 val = ini_sys:r_float_ex(arte:section(),"additional_inventory_weight") or 0
  103.                 art_weight_add = art_weight_add + val
  104.                 if (val > 0) then
  105.                     -- Which part of current carrying capacity comes from this belt item.
  106.                     -- Other items play their part as well. Multiple items will degrade
  107.                     -- slower than one item would, since they all share the load.
  108.                     local effect = val / max_weight
  109.                     -- Just how loaded the actor is.
  110.                     local actor_load = db.actor:get_total_weight() / max_weight
  111.                     -- This way items will not degrade when the actor is completely overloaded,
  112.                     -- otherwise the player will be trying to reduce carryweight in a race against degrading carrying capacity.
  113.                     -- Just imagine that all items automatically shut down when the actor is loaded over capacity.
  114.                     if actor_load <= 1 then
  115.                         cond_loss = cond_loss + (actor_load * effect * mul["weight"])
  116.                     end
  117.                 end
  118.            
  119.                
  120.                 if (cond_loss > 0) then
  121.                     --printf("%s Degradation: cond_loss=%s",arte:name(),cond_loss)
  122.                     local degrade_rate = (cond_loss*ini_sys:r_float_ex(arte:section(),"degrade_rate",1))
  123.                     if (arte:condition() - degrade_rate >= 0.01) then
  124.                         arte:set_condition(arte:condition() - degrade_rate)
  125.                     else
  126.                         arte:set_condition(0.01)
  127.                     end
  128.                 end
  129.             end
  130.         end
  131.     end
  132.    
  133.     return false
  134. end
  135.  
  136. function activate_feature()
  137.     _g.printf("-Artefact/Backpack degradation started")
  138.    
  139.     imm_mul = imm_mul or {                  -- correction factors for hit events
  140.         ["light_burn_immunity"] = 1.2,
  141.         ["burn_immunity"] = 1.2,
  142.         ["strike_immunity"] = 1.2,
  143.         ["shock_immunity"] = 1.2,
  144.         ["wound_immunity"] = 1.2,
  145.         ["radiation_immunity"] = 1.2,
  146.         ["telepatic_immunity"] = 1.2,
  147.         ["chemical_burn_immunity"] = 1.2,
  148.         ["explosion_immunity"] = 1.2,
  149.         ["fire_wound_immunity"] = 1.2,
  150.     }
  151.  
  152.     mul = mul or {                      -- correction factors for timed checks
  153.         ["health"]      = 0.4,      -- updated often while slotted so don't set too high
  154.         ["radiation"]   = 0.4,
  155.         ["satiety"]     = 0.4,
  156.         ["power"]       = 0.4,      -- updated often while slotted so don't set too high
  157.         ["bleeding"]    = 0.4,
  158.         ["psy_health"]  = 0.4,
  159.         ["weight"]      = 0.0002,   -- updated often while slotted so don't set too high
  160.     }
  161.  
  162.     RegisterScriptCallback("actor_on_item_drop",actor_on_item_drop)
  163.     RegisterScriptCallback("actor_on_before_hit",actor_on_before_hit)
  164.     RegisterScriptCallback("actor_item_to_belt",actor_item_to_belt)
  165.     AddUniqueCall(main_loop)
  166. end
  167.  
  168. function deactivate_feature()
  169.     _g.printf("-Artefact/Backpack degradation stopped")
  170.    
  171.     RemoveUniqueCall(main_loop)
  172.     UnregisterScriptCallback("actor_on_item_drop",actor_on_item_drop)
  173.     UnregisterScriptCallback("actor_on_before_hit",actor_on_before_hit)
  174.     UnregisterScriptCallback("actor_item_to_belt",actor_item_to_belt)  
  175. end
  176.  
  177. function toggle_feature_arty_degradation()
  178. end
  179.  
  180. function set_feature_arty_degradation()
  181.     if (artefact_degradation_feature) then
  182.         activate_feature()
  183.     else
  184.         deactivate_feature()
  185.     end
  186. end
  187.  
  188. --------------------------------------------------------------------------
  189. -- Belt HUD
  190. --------------------------------------------------------------------------
  191. HUD = nil
  192.  
  193. function activate_hud()
  194.     RegisterScriptCallback("actor_item_to_belt",actor_on_item_change)
  195.     RegisterScriptCallback("actor_item_to_ruck",actor_on_item_change)
  196.     RegisterScriptCallback("actor_on_item_drop",actor_on_item_change)
  197.     RegisterScriptCallback("on_console_execute",on_console_execute)
  198.     RegisterScriptCallback("actor_on_net_destroy",actor_on_net_destroy)
  199.     RegisterScriptCallback("GUI_on_show",update_hud)
  200.     RegisterScriptCallback("GUI_on_hide",update_hud)
  201.    
  202.     if HUD == nil then
  203.         HUD = UIBelt()
  204.         get_hud():AddDialogToRender(HUD)
  205.     end
  206.     HUD:Refresh()
  207. end
  208.  
  209. function deactivate_hud()
  210.     if HUD ~= nil then
  211.         get_hud():RemoveDialogToRender(HUD)
  212.         HUD = nil
  213.     end
  214.    
  215.     UnregisterScriptCallback("actor_item_to_belt",actor_on_item_change)
  216.     UnregisterScriptCallback("actor_item_to_ruck", actor_on_item_change)
  217.     UnregisterScriptCallback("actor_on_item_drop",actor_on_item_change)
  218.     UnregisterScriptCallback("on_console_execute",on_console_execute)
  219.     UnregisterScriptCallback("actor_on_net_destroy",actor_on_net_destroy)
  220.     UnregisterScriptCallback("GUI_on_show",update_hud)
  221.     UnregisterScriptCallback("GUI_on_hide",update_hud)
  222. end
  223.  
  224. function update_hud()
  225.     if HUD ~= nil then
  226.         HUD:Refresh()
  227.     end
  228. end
  229.  
  230. function actor_on_net_destroy()
  231.     if HUD ~= nil then
  232.         get_hud():RemoveDialogToRender(HUD)
  233.         HUD = nil
  234.     end
  235. end
  236.  
  237. function actor_on_item_change(item)
  238.     if HUD and IsArtefact(item) then
  239.         HUD:Refresh()
  240.     end
  241. end
  242.  
  243. function on_option_change()
  244.     local state = ui_options.get("video/hud/show_slots")
  245.     if state and (not HUD) then
  246.         activate_hud()
  247.     elseif (not state) and HUD then
  248.         deactivate_hud()
  249.     end
  250. end
  251.  
  252. function on_console_execute(name)
  253.     if name == "hud_draw" and HUD then
  254.         HUD:Refresh()
  255.     end
  256. end
  257.  
  258. function on_game_start()
  259.     RegisterScriptCallback("on_option_change",on_option_change)
  260.    
  261.     if (ui_options.get("video/hud/show_slots") == false) then
  262.         return
  263.     end
  264.    
  265.     local function actor_on_first_update()
  266.         set_feature_arty_degradation()
  267.         activate_hud()
  268.         RegisterScriptCallback("on_console_execute",on_console_execute)
  269.     end
  270.     RegisterScriptCallback("actor_on_first_update",actor_on_first_update)
  271. end
  272.  
  273.  
  274. ----------------------------------------------------
  275. class "UIBelt" (CUIScriptWnd)
  276.  
  277. function UIBelt:__init() super()
  278.     self.slot = {}
  279.    
  280.     self.mirrored = true
  281.     self.W      = 25
  282.     self.offset = 10
  283.  
  284.     self._tmr = time_global()
  285.     self:InitControls()
  286. end
  287.  
  288. function UIBelt:__finalize()
  289. end
  290.  
  291. function UIBelt:InitControls()
  292.     local xml = utils_xml.get_hud_xml()
  293.    
  294.     self.dialog = xml:InitStatic("belt", self)
  295.     --utils_xml.correct_ratio(self.dialog)
  296.     self.dialog:Show(false)
  297.    
  298.     for i=1, 5 do
  299.         local x = (i-1)*(self.W + self.offset)
  300.         if self.mirrored then
  301.             x = (1-i)*(self.W + self.offset)
  302.         end
  303.        
  304.         self.slot[i] = {}
  305.         self.slot[i].ico = xml:InitStatic("belt:slot", self.dialog)
  306.         self.slot[i].layer = xml:InitStatic("belt:slot", self.dialog)
  307.        
  308.         for k, ele in pairs(self.slot[i]) do
  309.             ele:SetWndPos( vector2():set( x , 0 ) )
  310.             utils_xml.correct_ratio(ele)
  311.         end
  312.     end
  313. end
  314.  
  315. function UIBelt:Clear()
  316.     for i=1,5 do
  317.         self.slot[i].ico:Show(false)
  318.         self.slot[i].layer:Show(false)
  319.     end
  320. end
  321.  
  322. function UIBelt:Refresh()
  323.     local cnt = 0
  324.    
  325.     self:Clear()
  326.    
  327.     if not main_hud_shown() then
  328.         return
  329.     end
  330.    
  331.     db.actor:iterate_belt( function(owner, obj)
  332.         local sec = obj:section()
  333.         cnt = cnt + 1
  334.         self.slot[cnt].ico:InitTexture( utils_xml.get_icons_texture(sec) )
  335.         self.slot[cnt].ico:SetTextureRect(Frect():set( utils_xml.get_item_axis(sec, nil, true) ))
  336.         self.slot[cnt].ico:Show(true)
  337.        
  338.         -- Set up indicator icon if found
  339.         local ico_layer = ini_sys:r_string_ex(sec,"1icon_layer")
  340.         if ico_layer then
  341.             local ico_layer_x = ini_sys:r_float_ex(sec,"1icon_layer_x")
  342.             local ico_layer_y = ini_sys:r_float_ex(sec,"1icon_layer_y")
  343.             local ico_layer_scale = ini_sys:r_float_ex(sec,"1icon_layer_scale")
  344.  
  345.             local pos = self.slot[cnt].ico:GetWndPos()
  346.             local w = self.slot[cnt].ico:GetWidth()
  347.             local h = self.slot[cnt].ico:GetHeight()
  348.             local ratio = w/50
  349.             --print_dbg("UIBelt: icon [%s](%s) | x = %s / y = %s / w = %s / h = %s", sec, cnt, pos.x , pos.y , w , h )
  350.            
  351.             local x_i = pos.x + math.ceil(ico_layer_x * ico_layer_scale * ratio)
  352.             local y_i = pos.y + math.ceil(ico_layer_y * ico_layer_scale * ratio)
  353.             local w_i = math.ceil(w * ico_layer_scale)
  354.             local h_i = math.ceil(h * ico_layer_scale)
  355.             self.slot[cnt].layer:InitTexture( utils_xml.get_icons_texture(ico_layer) )
  356.             self.slot[cnt].layer:SetWndPos(vector2():set( x_i , y_i ))
  357.             self.slot[cnt].layer:SetWndSize(vector2():set( w_i , h_i ))
  358.             --print_dbg("UIBelt: indicator [%s](%s) | scale: %s / x = %s / y = %s / w = %s / h = %s", sec, cnt, ico_layer_scale, x_i , y_i , w_i , h_i )
  359.            
  360.             self.slot[cnt].layer:SetTextureRect(Frect():set( utils_xml.get_item_axis(ico_layer, nil, true) ))
  361.             self.slot[cnt].layer:Show(true)
  362.         end
  363.     end)
  364.  
  365.     self.dialog:Show(cnt > 0)
  366. end
  367.  
  368. function UIBelt:Update()
  369.    
  370.     local tg = time_global()
  371.     if self._tmr >= tg then
  372.         return
  373.     else
  374.         self._tmr = tg + 10000
  375.     end
  376.    
  377.     self:Refresh()
  378.     CUIScriptWnd.Update(self)
  379. end
  380.  
  381. --------------------------------------------------------------------------
  382. -- Callbacks
  383. --------------------------------------------------------------------------
  384. function actor_on_item_drop(art)
  385.     if not IsArtefact(art) then
  386.         return
  387.     end
  388.     local art_id = art:id()
  389.     for k,v in pairs(belted_arts) do
  390.         if k == art_id then
  391.             belted_arts[k] = nil
  392.             return
  393.         end
  394.     end
  395. end
  396.  
  397. function actor_item_to_belt(item)
  398.     if IsArtefact(item) then
  399.         belted_arts[item:id()] = true
  400.     end
  401. end
  402. --//-----------     On hit immunities checks
  403. local hit_to_section = {
  404.     [hit.light_burn] = "light_burn_immunity",
  405.     [hit.burn] = "burn_immunity",
  406.     [hit.strike] = "strike_immunity",
  407.     [hit.shock] = "shock_immunity",
  408.     [hit.wound] = "wound_immunity",
  409.     [hit.radiation] = "radiation_immunity",
  410.     [hit.telepatic] = "telepatic_immunity",
  411.     [hit.chemical_burn] = "chemical_burn_immunity",
  412.     [hit.explosion] = "explosion_immunity",
  413.     [hit.fire_wound] = "fire_wound_immunity",
  414. }
  415.  
  416. local equipement_damaging = {
  417.     ["light_burn_immunity"] = true,
  418.     ["burn_immunity"] = true,
  419.     ["strike_immunity"] = true,
  420.     ["wound_immunity"] = true,
  421.     ["chemical_burn_immunity"] = true,
  422.     ["explosion_immunity"] = true,
  423.     ["fire_wound_immunity"] = true,
  424. }
  425.  
  426. function actor_on_before_hit(s_hit)
  427.     if (s_hit.power <= 0) then
  428.         return
  429.     end
  430.  
  431.     local cond_loss = 0
  432.     local hit_absorbation_sect, imm_sect
  433.  
  434.     if (artefact_degradation_feature) then
  435.         for art_id,active in pairs(belted_arts) do
  436.             if (active) then
  437.                 local arte = level.object_by_id(art_id)
  438.                 if not (arte and db.actor:is_on_belt(arte)) then
  439.                     belted_arts[art_id] = nil
  440.                 else
  441.                     cond_loss = 0
  442.                     hit_absorbation_sect = ini_sys:r_string_ex(arte:section(),"hit_absorbation_sect")
  443.                    
  444.                     if (hit_absorbation_sect) then
  445.                         imm_sect = hit_to_section[s_hit.type]
  446.                         cond_loss = imm_sect and ini_sys:r_float_ex(hit_absorbation_sect,imm_sect) or 0
  447.                         if (cond_loss > 0) then
  448.                             cond_loss = (s_hit.power * imm_mul[imm_sect] * cond_loss)
  449.                             printf("%s Degradation: hit_power=%s cond_loss=%s",arte:name(),s_hit.power,cond_loss)
  450.                            
  451.                             local temp_cond = arte:condition() - (cond_loss*ini_sys:r_float_ex(arte:section(),"degrade_rate",1))
  452.                             temp_cond = temp_cond > 0.01 and temp_cond or 0.01
  453.                             arte:set_condition(temp_cond)
  454.                         end
  455.                     end
  456.                 end
  457.             end
  458.         end
  459.     end
  460.    
  461.     local backpack = db.actor:item_in_slot(13)
  462.     if (backpack) and (backpack_degradation_feature) then
  463.         cond_loss = 0
  464.         hit_absorbation_sect = ini_sys:r_string_ex("stalker_outfit","immunities_sect")
  465.         if (hit_absorbation_sect) and (equipement_damaging[hit_to_section[s_hit.type]]) then
  466.             imm_sect = hit_to_section[s_hit.type]
  467.             cond_loss = imm_sect and ini_sys:r_float_ex(hit_absorbation_sect,imm_sect)*0.5 or 0
  468.             cond_loss = cond_loss * s_hit.power
  469.             if (cond_loss > 0) then
  470.                 --printf("%s Degradation: hit_power=%s cond_loss=%s",backpack:name(),s_hit.power,cond_loss)
  471.                 local temp_cond = backpack:condition() - (cond_loss*ini_sys:r_float_ex(backpack:section(),"degrade_rate",1))
  472.                 temp_cond = temp_cond > 0.01 and temp_cond or 0.01
  473.                 backpack:set_condition(temp_cond)
  474.             end
  475.         end
  476.     end
  477. end
  478.  
  479.  
  480. --------------------------------------------------------------------------------
  481. -- Class "artefact_binder"
  482. --------------------------------------------------------------------------------
  483. function printf()
  484. end
  485.  
  486. function bind(obj)
  487.     obj:bind_object(artefact_binder(obj))
  488. end
  489.  
  490. class "artefact_binder" (object_binder)
  491. function artefact_binder:__init(obj) super(obj)
  492.     db.storage[self.object:id()] = { }
  493. end
  494.  
  495. function artefact_binder:net_spawn(se_abstract)
  496.     if not object_binder.net_spawn(self, se_abstract) then
  497.         return false
  498.     end
  499.    
  500.     db.add_obj(self.object)
  501.     local artefact = self.object:get_artefact()
  502.     local id = self.object:id()
  503.     if bind_anomaly_zone.artefact_ways_by_id[id] ~= nil then
  504.         local anomal_zone = bind_anomaly_zone.parent_zones_by_artefact_id[id]
  505.         local force_xz  = anomal_zone.applying_force_xz
  506.         local force_y   = anomal_zone.applying_force_y
  507.         artefact:FollowByPath(bind_anomaly_zone.artefact_ways_by_id[id],bind_anomaly_zone.artefact_points_by_id[id],vector():set(force_xz,force_y,force_xz))
  508. --      artefact:FollowByPath(bind_anomaly_zone.artefact_ways_by_id[id],0,vector():set(force_xz,force_y,force_xz))
  509.     end
  510.  
  511.     self.first_call = true
  512.    
  513.     local tg = time_global()
  514.     self._tmr_rad = tg
  515.     self._tmr_dgr = tg
  516.    
  517.     return true
  518. end
  519. function artefact_binder:update(delta)
  520.     object_binder.update(self, delta)
  521.     printf("pl:art [%s] pos %s", self.object:name(), vec_to_str(self.object:position()))
  522.    
  523.     if self.first_call == true then
  524.         local se_obj = alife_object(self.object:id())
  525.         if (se_obj) then
  526.             local m_data = alife_storage_manager.get_se_obj_state(se_obj)
  527.             if (m_data and m_data.offline_condition) then
  528.                 printf("loaded condition "..tonumber(m_data.offline_condition))
  529.                 self.object:set_condition(tonumber(m_data.offline_condition) or 0.9999999)
  530.                 m_data.offline_condition = nil
  531.             end
  532.         end                              
  533.         local ini = self.object:spawn_ini()
  534.         if not (ini and ini:section_exist("fixed_bone")) then
  535.             self.first_call = false
  536.             return
  537.         end
  538.         local bone_name = ini:r_string_ex("fixed_bone", "name")
  539.  
  540.         local ph_shell = self.object:get_physics_shell()
  541.         if not ph_shell then
  542.             --printf("no ph shell")
  543.             return
  544.         end
  545.  
  546.         local ph_element = ph_shell:get_element_by_bone_name(bone_name)
  547.  
  548.         if ph_element:is_fixed() then
  549.             --printf("OBJECT FIXED")
  550.         else
  551.             --printf("FIXING OBJECT")
  552.             ph_element:fix()
  553.         end
  554.        
  555.         self.first_call = false
  556.  
  557.  
  558.     end
  559.    
  560.         local obj = self.object
  561.         local cobj = obj:cast_Artefact()
  562.         if (not cobj) then
  563.             return
  564.         end
  565.         local tg = time_global()
  566.         local val = 0
  567.        
  568.         if (tg > self._tmr_rad) and (not self.no_rad) and in_actor_ruck(obj) then
  569.             self._tmr_rad = tg + rad_tg_step
  570.    
  571.         -- Get radiation restore speed
  572.         local rad_val = cobj.m_fRadiationRestoreSpeed or 0
  573.        
  574.         -- No process for artefacts with no / healing rad effect
  575.         if (self.no_rad == nil) then
  576.             self.no_rad = (rad_val <= 0)
  577.             if self.no_rad then
  578.                 --print_dbg("Inventory radiation | artefact [%s] is not harmful -> exclude!", obj:name())
  579.                 return
  580.             end
  581.         end
  582.  
  583.         -- Apply radiation on actor
  584.         local rad_delta = rad_val * rad_factor
  585.         db.actor:change_radiation(rad_delta)
  586.        
  587.         --print_dbg("Inventory radiation | artefact: %s - radiation effect: %s", obj:name(), rad_delta)
  588.         end
  589. end
  590.  
  591. function artefact_binder:net_destroy(se_abstract)
  592.     db.del_obj(self.object)
  593.     object_binder.net_destroy(self)
  594. end
  595.  
  596. function artefact_binder:load(stpk)
  597.     object_binder.load(self,stpk)
  598. end
  599.  
  600. function artefact_binder:save(stpk)
  601.     object_binder.save(self,stpk)
  602.     local se_obj = alife_object(self.object:id())
  603.     if (se_obj) then
  604.         local m_data = alife_storage_manager.get_se_obj_state(se_obj)
  605.         if (m_data) then
  606.             m_data.offline_condition = self.object:condition()
  607.             printf("saved condition "..tonumber(m_data.offline_condition))                                                                 
  608.         end
  609.     end
  610. end
  611.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement