Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Ammo damp refactored
- local tmr
- local ini = system_ini()
- function on_game_start()
- RegisterScriptCallback("actor_on_update",actor_on_update)
- end
- function actor_on_update()
- if surge_manager.actor_in_cover == true then return end
- local diff = tmr and game.get_game_time():diffSec(tmr) or 3600
- if (diff < 3600) then
- return
- end
- tmr = game.get_game_time()
- local dampness_chance = math.ceil(level.rain_factor()*100)
- local backpack = db.actor:item_in_slot(13)
- backpack = backpack and backpack:section()
- if backpack then
- if (backpack == "backpack_heavy") then
- dampness_chance = math.ceil(dampness_chance/10)
- elseif (backpack == "backpack_tourist") then
- dampness_chance = math.ceil(dampness_chance/3)
- elseif ((backpack == "backpack_specops") or (backpack == "backpack_military")) then
- dampness_chance = math.ceil(dampness_chance/6)
- end
- end
- local function damp_ammo(dummy, item)
- local sec = item:section()
- if sec and IsAmmo(item) and ini:section_exist(sec.."_bad") then
- --printf("inventory item:%s",sec)
- local org_cnt = item:ammo_get_count()
- local new_cnt = math.floor(org_cnt * (100-dampness_chance) / 100)
- if new_cnt > 0 then
- item:ammo_set_count(new_cnt)
- else
- alife():release(alife_object(item:id()),true)
- end
- create_ammo(sec.."_bad",db.actor:position(),db.actor:level_vertex_id(),db.actor:game_vertex_id(),0,org_cnt - new_cnt)
- end
- end
- --printf("dampness:%s",dampness_chance)
- if (dampness_chance >= 2000) then -- 5% chance of failure with no backpack and 100% rain
- db.actor:iterate_inventory(damp_ammo)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment