Skip to content

Commit

Permalink
Option for autounload weapon after picking up (#496, closes #274)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rietmon authored and Xottab-DUTY committed Oct 19, 2019
1 parent b4dd792 commit d19a71b
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions res/gamedata/configs/text/eng/openxray.xml
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="windows-1251" ?>
<string_table>
<string id="st_unload_magazine_after_pickup">
<text>Autounload weapon after pickup</text>
</string>
<string id="st_unload_magazine_all">
<text>unload all weapons</text>
</string>
Expand Down
3 changes: 3 additions & 0 deletions res/gamedata/configs/text/rus/openxray.xml
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="windows-1251" ?>
<string_table>
<string id="st_unload_magazine_after_pickup">
<text>Ðàçðÿæàòü îð. ïðè ïîäíÿòèè</text>
</string>
<string id="st_unload_magazine_all">
<text>ðàçðÿäèòü âñ¸ îðóæèå</text>
</string>
Expand Down
9 changes: 9 additions & 0 deletions res/gamedata/configs/ui/ui_mm_opt.xml
Expand Up @@ -705,6 +705,15 @@
<options_item entry="rs_loadingstages" group="mm_opt_gameplay" is_integer="1"/>
</check_loadingstages>

<cap_unload_after_pickup x="20" y="3" width="135" height="24">
<text r="170" g="170" b="170" font="letterica16" align="r" vert_align="c">st_unload_magazine_after_pickup</text>
</cap_unload_after_pickup>

<unload_after_pickup x="167" y="0" width="44" height="29">
<texture>ui_inGame2_checkbox</texture>
<options_item entry="g_unload_ammo_after_pick_up" group="mm_opt_gameplay" is_integer="1"/>
</unload_after_pickup>

<btn_check_updates x="338" y="322" width="108" height="24">
<text align="c" font="letterica16">ui_mm_check_updates</text>
<texture>ui_inGame2_button</texture>
Expand Down
9 changes: 9 additions & 0 deletions res/gamedata/configs/ui/ui_mm_opt_16.xml
Expand Up @@ -707,6 +707,15 @@
<options_item entry="rs_loadingstages" group="mm_opt_gameplay" is_integer="1"/>
</check_loadingstages>

<cap_unload_after_pickup x="16" y="3" width="108" height="24">
<text r="170" g="170" b="170" font="letterica16" align="r" vert_align="c">st_unload_magazine_after_pickup</text>
</cap_unload_after_pickup>

<unload_after_pickup x="133" y="0" width="35" stretch="1" height="29">
<texture>ui_inGame2_checkbox</texture>
<options_item entry="g_unload_ammo_after_pick_up" group="mm_opt_gameplay" is_integer="1"/>
</unload_after_pickup>

<btn_check_updates x="270" y="322" width="86" height="24" stretch="1">
<text align="c" font="letterica16">ui_mm_check_updates</text>
<texture>ui_inGame2_button</texture>
Expand Down
5 changes: 5 additions & 0 deletions res/gamedata/scripts/ui_mm_opt_gameplay.script
Expand Up @@ -98,6 +98,11 @@ function opt_gameplay:InitControls(x, y, xml, handler)
xml:InitCheck("tab_gameplay:check_loadingstages", _st)
self.scroll_v:AddWindow(_st, true)

_st = xml:InitStatic("tab_gameplay:templ_item", nil)
xml:InitStatic("tab_gameplay:cap_unload_after_pickup", _st)
xml:InitCheck("tab_gameplay:unload_after_pickup", _st)
self.scroll_v:AddWindow(_st, true)

local btn
btn = xml:Init3tButton ("tab_gameplay:btn_check_updates", self)
handler:Register (btn, "btn_check_updates")
Expand Down
6 changes: 6 additions & 0 deletions src/xrGame/Inventory.cpp
Expand Up @@ -30,6 +30,7 @@ u16 INV_STATE_CAR = INV_STATE_LADDER;
u16 INV_STATE_BLOCK_ALL = 0xffff;
u16 INV_STATE_INV_WND = INV_STATE_BLOCK_ALL;
u16 INV_STATE_BUY_MENU = INV_STATE_BLOCK_ALL;
int g_auto_ammo_unload = 0;

bool defaultSlotActiveness[] =
{
Expand Down Expand Up @@ -190,6 +191,11 @@ void CInventory::Take(CGameObject* pObj, bool bNotActivate, bool strict_placemen
{
result = Ruck(pIItem, strict_placement);
VERIFY(result);
CWeaponMagazined* pWeapon = smart_cast<CWeaponMagazined*>(pIItem);
if (pWeapon && result && g_auto_ammo_unload)
{
pWeapon->UnloadMagazine();
}
}
}
else
Expand Down
2 changes: 2 additions & 0 deletions src/xrGame/console_commands.cpp
Expand Up @@ -76,6 +76,7 @@ ENGINE_API
extern float psHUD_FOV;
extern float psSqueezeVelocity;
extern int psLUA_GCSTEP;
extern int g_auto_ammo_unload;

extern int x_m_x;
extern int x_m_z;
Expand Down Expand Up @@ -2025,6 +2026,7 @@ void CCC_RegisterCommands()
CMD3(CCC_Mask, "g_important_save", &psActorFlags, AF_IMPORTANT_SAVE);
CMD4(CCC_Integer, "g_inv_highlight_equipped", &g_inv_highlight_equipped, 0, 1);
CMD4(CCC_Integer, "g_first_person_death", &g_first_person_death, 0, 1);
CMD4(CCC_Integer, "g_unload_ammo_after_pick_up", &g_auto_ammo_unload, 0, 1);

CMD1(CCC_CleanupTasks, "dbg_cleanup_tasks");

Expand Down

0 comments on commit d19a71b

Please sign in to comment.