Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bypass engine reload and force weapon into reload state
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |