From 93fdfa1ab4cdaa59c6ab63550f716cebbc1c5e49 Mon Sep 17 00:00:00 2001 From: Qustinnus Date: Mon, 8 Mar 2021 14:17:19 +0100 Subject: [PATCH] Adds a hotkey that puts you in throw mode aslong as you hold it (#57331) Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> --- code/__DEFINES/keybinding.dm | 1 + code/__DEFINES/mobs.dm | 6 +++++ code/_onclick/click.dm | 2 +- code/datums/components/tackle.dm | 2 +- code/datums/keybinding/carbon.dm | 25 +++++++++++++++++-- code/datums/martial/sleeping_carp.dm | 2 +- code/datums/mutations/hulk.dm | 2 +- .../game/gamemodes/clown_ops/clown_weapons.dm | 4 +-- code/game/objects/effects/mines.dm | 4 +-- code/game/objects/items/stunbaton.dm | 7 ++++++ .../changeling/powers/mutations.dm | 6 ++--- code/modules/client/preferences_savefile.dm | 4 ++- code/modules/hydroponics/grown/citrus.dm | 3 --- code/modules/mob/living/carbon/carbon.dm | 18 +++++++------ .../mob/living/carbon/carbon_defense.dm | 4 +-- .../mob/living/carbon/human/human_defense.dm | 2 +- code/modules/mob/mob_defines.dm | 2 +- .../ninja_equipment_actions/ninja_stars.dm | 1 - code/modules/paperwork/paperplane.dm | 2 +- code/modules/spells/spell_types/wizard.dm | 2 +- code/modules/surgery/organs/vocal_cords.dm | 2 +- 21 files changed, 66 insertions(+), 35 deletions(-) diff --git a/code/__DEFINES/keybinding.dm b/code/__DEFINES/keybinding.dm index 2743de54aa3..b379ee2fa09 100644 --- a/code/__DEFINES/keybinding.dm +++ b/code/__DEFINES/keybinding.dm @@ -19,6 +19,7 @@ #define COMSIG_KB_CARBON_HOLDRUNMOVEINTENT_DOWN "keybinding_carbon_holdrunmoveintent_down" #define COMSIG_KB_CARBON_HOLDRUNMOVEINTENT_UP "keybinding_carbon_holdrunmoveintent_up" #define COMSIG_KB_CARBON_TOGGLETHROWMODE_DOWN "keybinding_carbon_togglethrowmode_down" +#define COMSIG_KB_CARBON_HOLDTHROWMODE_DOWN "keybinding_carbon_holdthrowmode_down" #define COMSIG_KB_CARBON_GIVEITEM_DOWN "keybinding_carbon_giveitem_down" //Client diff --git a/code/__DEFINES/mobs.dm b/code/__DEFINES/mobs.dm index acbc061cd17..09514c04197 100644 --- a/code/__DEFINES/mobs.dm +++ b/code/__DEFINES/mobs.dm @@ -442,3 +442,9 @@ #define AI_EMOTION_DORFY "Dorfy" #define AI_EMOTION_BLUE_GLOW "Blue Glow" #define AI_EMOTION_RED_GLOW "Red Glow" + +/// Throw modes, defines whether or not to turn off throw mode after +#define THROW_MODE_DISABLED 0 +#define THROW_MODE_TOGGLE 1 +#define THROW_MODE_HOLD 2 + diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index fa6c4970453..520e3ddc739 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -114,7 +114,7 @@ UnarmedAttack(A, FALSE, modifiers) return - if(in_throw_mode) + if(throw_mode) changeNext_move(CLICK_CD_THROW) throw_item(A) return diff --git a/code/datums/components/tackle.dm b/code/datums/components/tackle.dm index b6196f608fe..5a9fed12cc7 100644 --- a/code/datums/components/tackle.dm +++ b/code/datums/components/tackle.dm @@ -71,7 +71,7 @@ /datum/component/tackler/proc/checkTackle(mob/living/carbon/user, atom/A, params) SIGNAL_HANDLER - if(!user.in_throw_mode || user.get_active_held_item() || user.pulling || user.buckled || user.incapacitated()) + if(!user.throw_mode || user.get_active_held_item() || user.pulling || user.buckled || user.incapacitated()) return if(!A || !(isturf(A) || isturf(A.loc))) diff --git a/code/datums/keybinding/carbon.dm b/code/datums/keybinding/carbon.dm index 97419cf60fb..b7ff66694e1 100644 --- a/code/datums/keybinding/carbon.dm +++ b/code/datums/keybinding/carbon.dm @@ -21,6 +21,27 @@ C.toggle_throw_mode() return TRUE +/datum/keybinding/carbon/hold_throw_mode + hotkey_keys = list("Space") + name = "hold_throw_mode" + full_name = "Hold throw mode" + description = "Hold this to turn on throw mode, and release it to turn off throw mode" + category = CATEGORY_CARBON + keybind_signal = COMSIG_KB_CARBON_HOLDTHROWMODE_DOWN + +/datum/keybinding/carbon/hold_throw_mode/down(client/user) + . = ..() + if(.) + return + var/mob/living/carbon/carbon_user = user.mob + carbon_user.throw_mode_on(THROW_MODE_HOLD) + +/datum/keybinding/carbon/hold_throw_mode/up(client/user) + . = ..() + if(.) + return + var/mob/living/carbon/carbon_user = user.mob + carbon_user.throw_mode_off(THROW_MODE_HOLD) /datum/keybinding/carbon/give hotkey_keys = list("G") name = "Give_Item" @@ -32,6 +53,6 @@ . = ..() if(.) return - var/mob/living/carbon/C = user.mob - C.give() + var/mob/living/carbon/carbon_user = user.mob + carbon_user.give() return TRUE diff --git a/code/datums/martial/sleeping_carp.dm b/code/datums/martial/sleeping_carp.dm index 0fcf22f4938..e53723b3bcc 100644 --- a/code/datums/martial/sleeping_carp.dm +++ b/code/datums/martial/sleeping_carp.dm @@ -109,7 +109,7 @@ return BULLET_ACT_HIT if(!isturf(A.loc)) //NO MOTHERFLIPPIN MECHS! return BULLET_ACT_HIT - if(A.in_throw_mode) + if(A.throw_mode) A.visible_message("[A] effortlessly swats the projectile aside! They can block bullets with their bare hands!", "You deflect the projectile!") playsound(get_turf(A), pick('sound/weapons/bulletflyby.ogg', 'sound/weapons/bulletflyby2.ogg', 'sound/weapons/bulletflyby3.ogg'), 75, TRUE) P.firer = A diff --git a/code/datums/mutations/hulk.dm b/code/datums/mutations/hulk.dm index ae92c92dc97..e6b74eb74da 100644 --- a/code/datums/mutations/hulk.dm +++ b/code/datums/mutations/hulk.dm @@ -104,7 +104,7 @@ var/list/modifiers = params2list(params) if(LAZYACCESS(modifiers, ALT_CLICK) || LAZYACCESS(modifiers, SHIFT_CLICK) || LAZYACCESS(modifiers, CTRL_CLICK) || LAZYACCESS(modifiers, MIDDLE_CLICK)) return - if(!user.in_throw_mode || user.get_active_held_item() || user.zone_selected != BODY_ZONE_PRECISE_GROIN) + if(!user.throw_mode || user.get_active_held_item() || user.zone_selected != BODY_ZONE_PRECISE_GROIN) return if(user.grab_state < GRAB_NECK || !iscarbon(user.pulling) || user.buckled || user.incapacitated()) return diff --git a/code/game/gamemodes/clown_ops/clown_weapons.dm b/code/game/gamemodes/clown_ops/clown_weapons.dm index 5abc41ecf98..2cce19f96bc 100644 --- a/code/game/gamemodes/clown_ops/clown_weapons.dm +++ b/code/game/gamemodes/clown_ops/clown_weapons.dm @@ -159,7 +159,7 @@ if(active) if(iscarbon(thrower)) var/mob/living/carbon/C = thrower - C.throw_mode_on() //so they can catch it on the return. + C.throw_mode_on(THROW_MODE_TOGGLE) //so they can catch it on the return. return ..() /obj/item/shield/energy/bananium/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) @@ -200,8 +200,6 @@ bomb.det_time = det_time if(iscarbon(loc)) to_chat(loc, "[src] begins to beep.") - var/mob/living/carbon/C = loc - C.throw_mode_on() bomb.arm_grenade(loc, null, FALSE) /obj/item/grown/bananapeel/bombanana/ComponentInitialize() diff --git a/code/game/objects/effects/mines.dm b/code/game/objects/effects/mines.dm index c24d6827c47..fcb1d958789 100644 --- a/code/game/objects/effects/mines.dm +++ b/code/game/objects/effects/mines.dm @@ -182,9 +182,7 @@ . = ..() if(active) return - if(iscarbon(user)) - var/mob/living/carbon/user_human = user - user_human.throw_mode_on() + playsound(src, 'sound/weapons/armbomb.ogg', 70, TRUE) to_chat(user, "You arm \the [src], causing it to shake! It will deploy in 3 seconds.") diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index c043a53c9e1..59a47f6be1f 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -324,6 +324,13 @@ convertible = FALSE custom_materials = list(/datum/material/iron = 10000, /datum/material/glass = 4000, /datum/material/silver = 10000, /datum/material/gold = 2000) +/obj/item/melee/baton/boomerang/throw_at(atom/target, range, speed, mob/thrower, spin=1, diagonals_first = 0, datum/callback/callback, force, gentle = FALSE, quickstart = TRUE) + if(turned_on) + if(ishuman(thrower)) + var/mob/living/carbon/human/H = thrower + H.throw_mode_off(THROW_MODE_TOGGLE) //so they can catch it on the return. + return ..() + /obj/item/melee/baton/boomerang/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) if(turned_on) var/caught = hit_atom.hitby(src, FALSE, FALSE, throwingdatum=throwingdatum) diff --git a/code/modules/antagonists/changeling/powers/mutations.dm b/code/modules/antagonists/changeling/powers/mutations.dm index 7267f22991e..9ef697fdb12 100644 --- a/code/modules/antagonists/changeling/powers/mutations.dm +++ b/code/modules/antagonists/changeling/powers/mutations.dm @@ -318,8 +318,8 @@ ..() /obj/projectile/tentacle/proc/reset_throw(mob/living/carbon/human/H) - if(H.in_throw_mode) - H.throw_mode_off() //Don't annoy the changeling if he doesn't catch the item + if(H.throw_mode) + H.throw_mode_off(THROW_MODE_TOGGLE) //Don't annoy the changeling if he doesn't catch the item /obj/projectile/tentacle/proc/tentacle_grab(mob/living/carbon/human/H, mob/living/carbon/C) if(H.Adjacent(C)) @@ -349,7 +349,7 @@ var/obj/item/I = target if(!I.anchored) to_chat(firer, "You pull [I] towards yourself.") - H.throw_mode_on() + H.throw_mode_on(THROW_MODE_TOGGLE) I.throw_at(H, 10, 2) . = BULLET_ACT_HIT diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 22bae9318ec..c54ef4f4ddc 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -5,7 +5,7 @@ // You do not need to raise this if you are adding new values that have sane defaults. // Only raise this value when changing the meaning/format/name/layout of an existing value // where you would want the updater procs below to run -#define SAVEFILE_VERSION_MAX 39 +#define SAVEFILE_VERSION_MAX 40 /* SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn @@ -90,6 +90,8 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car if (current_version < 39) LAZYADD(key_bindings["F"], "toggle_combat_mode") LAZYADD(key_bindings["4"], "toggle_combat_mode") + if (current_version < 40) + LAZYADD(key_bindings["Space"], "hold_throw_mode") /datum/preferences/proc/update_character(current_version, savefile/S) return diff --git a/code/modules/hydroponics/grown/citrus.dm b/code/modules/hydroponics/grown/citrus.dm index 061f94f3c7f..cfaafc94b40 100644 --- a/code/modules/hydroponics/grown/citrus.dm +++ b/code/modules/hydroponics/grown/citrus.dm @@ -113,9 +113,6 @@ /obj/item/food/grown/firelemon/attack_self(mob/living/user) user.visible_message("[user] primes [src]!", "You prime [src]!") log_bomber(user, "primed a", src, "for detonation") - if(iscarbon(user)) - var/mob/living/carbon/C = user - C.throw_mode_on() icon_state = "firelemon_active" playsound(loc, 'sound/weapons/armbomb.ogg', 75, TRUE, -3) addtimer(CALLBACK(src, .proc/detonate), rand(10, 60)) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 5595747fa0e..0b586bb7cf2 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -119,20 +119,22 @@ /mob/living/carbon/proc/toggle_throw_mode() if(stat) return - if(in_throw_mode) - throw_mode_off() + if(throw_mode) + throw_mode_off(THROW_MODE_TOGGLE) else - throw_mode_on() + throw_mode_on(THROW_MODE_TOGGLE) -/mob/living/carbon/proc/throw_mode_off() - in_throw_mode = FALSE +/mob/living/carbon/proc/throw_mode_off(method) + if(throw_mode > method) //A toggle doesnt affect a hold + return + throw_mode = THROW_MODE_DISABLED if(hud_used) hud_used.throw_icon.icon_state = "act_throw_off" -/mob/living/carbon/proc/throw_mode_on() - in_throw_mode = TRUE +/mob/living/carbon/proc/throw_mode_on(mode = THROW_MODE_TOGGLE) + throw_mode = mode if(hud_used) hud_used.throw_icon.icon_state = "act_throw_on" @@ -143,7 +145,7 @@ /mob/living/carbon/throw_item(atom/target) . = ..() - throw_mode_off() + throw_mode_off(THROW_MODE_TOGGLE) if(!target || !isturf(loc)) return if(istype(target, /atom/movable/screen)) diff --git a/code/modules/mob/living/carbon/carbon_defense.dm b/code/modules/mob/living/carbon/carbon_defense.dm index 28b2489be51..dded55aa23e 100644 --- a/code/modules/mob/living/carbon/carbon_defense.dm +++ b/code/modules/mob/living/carbon/carbon_defense.dm @@ -46,7 +46,7 @@ /mob/living/carbon/proc/can_catch_item(skip_throw_mode_check) . = FALSE - if(!skip_throw_mode_check && !in_throw_mode) + if(!skip_throw_mode_check && !throw_mode) return if(get_active_held_item()) return @@ -61,7 +61,7 @@ if(get_active_held_item() == I) //if our attack_hand() picks up the item... visible_message("[src] catches [I]!", \ "You catch [I] in mid-air!") - throw_mode_off() + throw_mode_off(THROW_MODE_TOGGLE) return TRUE return ..() diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index 2c923af6230..58b832a06e1 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -141,7 +141,7 @@ /mob/living/carbon/human/proc/check_block() if(mind) - if(mind.martial_art && prob(mind.martial_art.block_chance) && mind.martial_art.can_use(src) && in_throw_mode && !incapacitated(FALSE, TRUE)) + if(mind.martial_art && prob(mind.martial_art.block_chance) && mind.martial_art.can_use(src) && throw_mode && !incapacitated(FALSE, TRUE)) return TRUE return FALSE diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index 6f159451956..5d7bf7d97aa 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -143,7 +143,7 @@ var/research_scanner = FALSE /// Is the mob throw intent on - var/in_throw_mode = FALSE + var/throw_mode = THROW_MODE_DISABLED /// What job does this mob have var/job = null//Living diff --git a/code/modules/ninja/suit/ninja_equipment_actions/ninja_stars.dm b/code/modules/ninja/suit/ninja_equipment_actions/ninja_stars.dm index 38c5c254476..dc6396ef503 100644 --- a/code/modules/ninja/suit/ninja_equipment_actions/ninja_stars.dm +++ b/code/modules/ninja/suit/ninja_equipment_actions/ninja_stars.dm @@ -21,7 +21,6 @@ else qdel(ninja_star) to_chat(ninja, "You can't create a throwing star, your hands are full!") - ninja.throw_mode_on() //So they can quickly throw it. /** * # Ninja Throwing Star diff --git a/code/modules/paperwork/paperplane.dm b/code/modules/paperwork/paperplane.dm index d8600939131..01140868b01 100644 --- a/code/modules/paperwork/paperplane.dm +++ b/code/modules/paperwork/paperplane.dm @@ -96,7 +96,7 @@ if(C.can_catch_item(TRUE)) var/datum/action/innate/origami/origami_action = locate() in C.actions if(origami_action?.active) //if they're a master of origami and have the ability turned on, force throwmode on so they'll automatically catch the plane. - C.throw_mode_on() + C.throw_mode_on(THROW_MODE_TOGGLE) if(..() || !ishuman(hit_atom))//if the plane is caught or it hits a nonhuman return diff --git a/code/modules/spells/spell_types/wizard.dm b/code/modules/spells/spell_types/wizard.dm index 231218df45c..9488d4ed9db 100644 --- a/code/modules/spells/spell_types/wizard.dm +++ b/code/modules/spells/spell_types/wizard.dm @@ -353,7 +353,7 @@ /obj/effect/proc_holder/spell/targeted/conjure_item/spellpacket/cast(list/targets, mob/user = usr) ..() for(var/mob/living/carbon/C in targets) - C.throw_mode_on() + C.throw_mode_on(THROW_MODE_TOGGLE) /obj/item/spellpacket/lightningbolt name = "\improper Lightning bolt Spell Packet" diff --git a/code/modules/surgery/organs/vocal_cords.dm b/code/modules/surgery/organs/vocal_cords.dm index 2b059a702b5..fd60d075574 100644 --- a/code/modules/surgery/organs/vocal_cords.dm +++ b/code/modules/surgery/organs/vocal_cords.dm @@ -417,7 +417,7 @@ else if((findtext(message, throwmode_words))) cooldown = COOLDOWN_MEME for(var/mob/living/carbon/C in listeners) - C.throw_mode_on() + C.throw_mode_on(THROW_MODE_TOGGLE) //FLIP else if((findtext(message, flip_words)))