Skip to content

Commit

Permalink
"Do nothing" dual wield preference (cmss13-devs#4504)
Browse files Browse the repository at this point in the history
# About the pull request

This PR adds a third option to the dual wield preference which is just
"do nothing".

# Explain why it's good for the game

I hate that there isn't an option that just allows me to do my own thing
rather than the game dictating that something *must* happen: either
forced swap hands or forced fire both weapons.

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog

:cl: Morrow
qol: "Do nothing" dual wield preference
/:cl:
  • Loading branch information
morrowwolf authored Sep 28, 2023
1 parent 26bf900 commit 54cab1d
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 17 deletions.
11 changes: 10 additions & 1 deletion code/__DEFINES/client_prefs.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#define BE_ALIEN_AFTER_DEATH (1<<0)
#define BE_AGENT (1<<1)

//toggle_prefs bits from /datum/preferences
#define TOGGLE_IGNORE_SELF (1<<0) // Determines whether you will not hurt yourself when clicking yourself
#define TOGGLE_HELP_INTENT_SAFETY (1<<1) // Determines whether help intent will be completely harmless
#define TOGGLE_MIDDLE_MOUSE_CLICK (1<<2) // This toggles whether selected ability for xeno uses middle mouse clicking or shift clicking
Expand All @@ -13,7 +14,7 @@
// and put the empty magazine in your hand
#define TOGGLE_AUTOMATIC_PUNCTUATION (1<<7) // Whether your sentences will automatically be punctuated with a period
#define TOGGLE_COMBAT_CLICKDRAG_OVERRIDE (1<<8) // Whether disarm/harm intents cause clicks to trigger immediately when the mouse button is depressed.
#define TOGGLE_ALTERNATING_DUAL_WIELD (1<<9) // Whether dual-wielding fires both guns at once or swaps between them.
#define TOGGLE_ALTERNATING_DUAL_WIELD (1<<9) // Whether dual-wielding fires both guns at once or swaps between them, OUTDATED, used to update savefiles, now dual_wield_pref
#define TOGGLE_FULLSCREEN (1<<10) // See /client/proc/toggle_fullscreen in client_procs.dm
#define TOGGLE_MEMBER_PUBLIC (1<<11) //determines if you get a byond logo by your name in ooc if you're a member or not
#define TOGGLE_OOC_FLAG (1<<12) // determines if your country flag appears by your name in ooc chat
Expand All @@ -32,3 +33,11 @@
#define AGE_MIN 19 //youngest a character can be
#define AGE_MAX 90 //oldest a character can be //no. you are not allowed to be 160.
#define MAX_GEAR_COST 7 //Used in chargen for loadout limit.

///dual_wield_pref from /datum/preferences
///Fire both weapons when dual wielding
#define DUAL_WIELD_FIRE 0
///Swap to the other weapon when dual wielding
#define DUAL_WIELD_SWAP 1
///Do nothing when dual wielding
#define DUAL_WIELD_NONE 2
4 changes: 2 additions & 2 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var/const/MAX_SAVE_SLOTS = 10
)
var/ghost_vision_pref = GHOST_VISION_LEVEL_MID_NVG
var/ghost_orbit = GHOST_ORBIT_CIRCLE
var/dual_wield_pref = DUAL_WIELD_FIRE

//Synthetic specific preferences
var/synthetic_name = "Undefined"
Expand Down Expand Up @@ -619,13 +620,12 @@ var/const/MAX_SAVE_SLOTS = 10
</b> <a href='?_src_=prefs;preference=toggle_prefs;flag=[TOGGLE_AUTOMATIC_PUNCTUATION]'><b>[toggle_prefs & TOGGLE_AUTOMATIC_PUNCTUATION ? "On" : "Off"]</b></a><br>"
dat += "<b>Toggle Combat Click-Drag Override: \
</b> <a href='?_src_=prefs;preference=toggle_prefs;flag=[TOGGLE_COMBAT_CLICKDRAG_OVERRIDE]'><b>[toggle_prefs & TOGGLE_COMBAT_CLICKDRAG_OVERRIDE ? "On" : "Off"]</b></a><br>"
dat += "<b>Toggle Alternate-Fire Dual Wielding: \
</b> <a href='?_src_=prefs;preference=toggle_prefs;flag=[TOGGLE_ALTERNATING_DUAL_WIELD]'><b>[toggle_prefs & TOGGLE_ALTERNATING_DUAL_WIELD ? "On" : "Off"]</b></a><br>"
dat += "<b>Toggle Middle-Click Swap Hands: \
</b> <a href='?_src_=prefs;preference=toggle_prefs;flag=[TOGGLE_MIDDLE_MOUSE_SWAP_HANDS]'><b>[toggle_prefs & TOGGLE_MIDDLE_MOUSE_SWAP_HANDS ? "On" : "Off"]</b></a><br>"
dat += "<b>Toggle Vendors Vending to Hands: \
</b> <a href='?_src_=prefs;preference=toggle_prefs;flag=[TOGGLE_VEND_ITEM_TO_HAND]'><b>[toggle_prefs & TOGGLE_VEND_ITEM_TO_HAND ? "On" : "Off"]</b></a><br>"
dat += "<a href='?src=\ref[src];action=proccall;procpath=/client/proc/switch_item_animations'>Toggle Item Animations Detail Level</a><br>"
dat += "<a href='?src=\ref[src];action=proccall;procpath=/client/proc/toggle_dualwield'>Toggle Dual Wield Functionality</a><br>"
if(MENU_SPECIAL) //wart
dat += "<div id='column1'>"
dat += "<h2><b><u>ERT Settings:</u></b></h2>"
Expand Down
14 changes: 13 additions & 1 deletion code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define SAVEFILE_VERSION_MIN 8
#define SAVEFILE_VERSION_MAX 20
#define SAVEFILE_VERSION_MAX 21

//handles converting savefiles to new formats
//MAKE SURE YOU KEEP THIS UP TO DATE!
Expand Down Expand Up @@ -80,6 +80,15 @@
sound_toggles |= (SOUND_ADMIN_MEME|SOUND_ADMIN_ATMOSPHERIC)
S["toggles_sound"] << sound_toggles

if(savefile_version < 21)
var/pref_toggles
S["toggle_prefs"] >> pref_toggles
if(pref_toggles & TOGGLE_ALTERNATING_DUAL_WIELD)
dual_wield_pref = DUAL_WIELD_SWAP
else
dual_wield_pref = DUAL_WIELD_FIRE
S["dual_wield_pref"] << dual_wield_pref

savefile_version = SAVEFILE_VERSION_MAX
return 1

Expand Down Expand Up @@ -125,6 +134,7 @@
S["toggles_langchat"] >> toggles_langchat
S["toggles_sound"] >> toggles_sound
S["toggle_prefs"] >> toggle_prefs
S["dual_wield_pref"] >> dual_wield_pref
S["toggles_flashing"] >> toggles_flashing
S["toggles_ert"] >> toggles_ert
S["toggles_admin"] >> toggles_admin
Expand Down Expand Up @@ -210,6 +220,7 @@
toggles_langchat = sanitize_integer(toggles_langchat, 0, SHORT_REAL_LIMIT, initial(toggles_langchat))
toggles_sound = sanitize_integer(toggles_sound, 0, SHORT_REAL_LIMIT, initial(toggles_sound))
toggle_prefs = sanitize_integer(toggle_prefs, 0, SHORT_REAL_LIMIT, initial(toggle_prefs))
dual_wield_pref = sanitize_integer(dual_wield_pref, 0, 2, initial(dual_wield_pref))
toggles_flashing= sanitize_integer(toggles_flashing, 0, SHORT_REAL_LIMIT, initial(toggles_flashing))
toggles_ert = sanitize_integer(toggles_ert, 0, SHORT_REAL_LIMIT, initial(toggles_ert))
toggles_admin = sanitize_integer(toggles_admin, 0, SHORT_REAL_LIMIT, initial(toggles_admin))
Expand Down Expand Up @@ -317,6 +328,7 @@
S["toggles_langchat"] << toggles_langchat
S["toggles_sound"] << toggles_sound
S["toggle_prefs"] << toggle_prefs
S["dual_wield_pref"] << dual_wield_pref
S["toggles_flashing"] << toggles_flashing
S["toggles_ert"] << toggles_ert
S["toggles_admin"] << toggles_admin
Expand Down
19 changes: 14 additions & 5 deletions code/modules/client/preferences_toggles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,21 @@
to_chat(src,SPAN_BOLDNOTICE( "Click-dragging now blocks clicks from going through."))
prefs.save_preferences()

/client/proc/toggle_dualwield() //Toggle whether dual-wielding fires both guns at once or swaps between them.
prefs.toggle_prefs ^= TOGGLE_ALTERNATING_DUAL_WIELD
if(prefs.toggle_prefs & TOGGLE_ALTERNATING_DUAL_WIELD)
to_chat(src, SPAN_BOLDNOTICE("Dual-wielding now switches between guns, as long as the other gun is loaded."))
///Toggle whether dual-wielding fires both guns at once or swaps between them.
/client/proc/toggle_dualwield()
if(prefs.dual_wield_pref < DUAL_WIELD_NONE)
prefs.dual_wield_pref++
else
to_chat(src, SPAN_BOLDNOTICE("Dual-wielding now fires both guns simultaneously."))
prefs.dual_wield_pref = DUAL_WIELD_FIRE

switch(prefs.dual_wield_pref)
if(DUAL_WIELD_FIRE)
to_chat(src, SPAN_BOLDNOTICE("Dual-wielding now fires both guns simultaneously."))
if(DUAL_WIELD_SWAP)
to_chat(src, SPAN_BOLDNOTICE("Dual-wielding now switches between guns, as long as the other gun is loaded."))
if(DUAL_WIELD_NONE)
to_chat(src, SPAN_BOLDNOTICE("Dual-wielding now has no effect on how you fire."))

prefs.save_preferences()

/client/proc/toggle_middle_mouse_swap_hands() //Toggle whether middle click swaps your hands
Expand Down
18 changes: 10 additions & 8 deletions code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1214,10 +1214,11 @@ and you're good to go.
shots_fired++

if(dual_wield && !fired_by_akimbo)
if(user?.client?.prefs?.toggle_prefs & TOGGLE_ALTERNATING_DUAL_WIELD)
user.swap_hand()
else
INVOKE_ASYNC(akimbo, PROC_REF(Fire), target, user, params, 0, TRUE)
switch(user?.client?.prefs?.dual_wield_pref)
if(DUAL_WIELD_FIRE)
INVOKE_ASYNC(akimbo, PROC_REF(Fire), target, user, params, 0, TRUE)
if(DUAL_WIELD_SWAP)
user.swap_hand()

else
return TRUE
Expand Down Expand Up @@ -1456,10 +1457,11 @@ and you're good to go.
SEND_SIGNAL(user, COMSIG_MOB_FIRED_GUN, src)

if(dual_wield && !fired_by_akimbo)
if(user?.client?.prefs?.toggle_prefs & TOGGLE_ALTERNATING_DUAL_WIELD)
user.swap_hand()
else
INVOKE_ASYNC(akimbo, PROC_REF(attack), attacked_mob, user, TRUE)
switch(user?.client?.prefs?.dual_wield_pref)
if(DUAL_WIELD_FIRE)
INVOKE_ASYNC(akimbo, PROC_REF(attack), attacked_mob, user, TRUE)
if(DUAL_WIELD_SWAP)
user.swap_hand()

if(EXECUTION_CHECK) //Continue execution if on the correct intent. Accounts for change via the earlier do_after
user.visible_message(SPAN_DANGER("[user] has executed [attacked_mob] with [src]!"), SPAN_DANGER("You have executed [attacked_mob] with [src]!"), message_flags = CHAT_TYPE_WEAPON_USE)
Expand Down

0 comments on commit 54cab1d

Please sign in to comment.