24 lines
765 B
Plaintext
24 lines
765 B
Plaintext
ini_parts = itms_manager.ini_parts
|
|
|
|
local function parent_section(sec)
|
|
return SYS_GetParam(0, sec,"parent_section") or sec
|
|
end
|
|
|
|
igi_actions.actions.break_item = function (action)
|
|
local item = igi_helper.level_object(action.id)
|
|
if not item then return end
|
|
if not IsWeapon(item) then return end
|
|
if IsMelee(item) then return end
|
|
|
|
-- Set overall item condition to low
|
|
item:set_condition(igi_random.rand(10, 40)/100)
|
|
|
|
-- Set condition of individual weapon parts to low
|
|
local sec = parent_section(item:section())
|
|
local parts = ini_parts:r_string_ex("con_parts_list", sec)
|
|
local parts_data = {}
|
|
for i,part in pairs(str_explode(parts, ",")) do
|
|
parts_data[part] = igi_random.rand(10, 40)
|
|
end
|
|
se_save_var( item:id(), item:name(), "parts", parts_data )
|
|
end |