Skip to content

Commit

Permalink
Implement ADS reloads
Browse files Browse the repository at this point in the history
Bypass engine reload and force weapon into reload state
  • Loading branch information
Aoldri committed Dec 18, 2022
1 parent 79e1c53 commit de16b32
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Universal Animation Scripts/ads_reloads.script
@@ -0,0 +1,32 @@
function is_valid_wpn(wpn)
local section = wpn:section()
local has_tristate_reload = ini_sys:r_string_ex(section,"tri_state_reload")
if has_tristate_reload then
if animation_common.has_animation(section, "anm_open_aim") then
return true
else
return false
end
else
if animation_common.has_animation(section, "anm_reload_aim") then
return true
else
return false
end
end
end

function on_before_key_press(key, bind, dis, flags)
if bind ~= key_bindings.kWPN_RELOAD then return end
local wpn = db.actor:item_in_slot(db.actor:active_slot())
if not wpn then return end
if not is_valid_wpn(wpn) then return end

wpn:switch_state(7)
flags.ret_value = false
end

function on_game_start()
if magazines then return end
RegisterScriptCallback("on_before_key_press", on_before_key_press)
end

0 comments on commit de16b32

Please sign in to comment.