Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ports holding down space to toggle throw mode from tg #6493

Merged
merged 3 commits into from May 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions code/__DEFINES/combat.dm
Expand Up @@ -50,6 +50,7 @@

//click cooldowns, in tenths of a second, used for various combat actions
#define CLICK_CD_MELEE 8
#define CLICK_CD_THROW 4
#define CLICK_CD_RANGE 4
#define CLICK_CD_RAPID 2
#define CLICK_CD_CLICK_ABILITY 6
Expand Down
1 change: 1 addition & 0 deletions code/__DEFINES/keybinding.dm
Expand Up @@ -18,6 +18,7 @@
#define COMSIG_KB_CARBON_SELECTDISARMINTENT_DOWN "keybinding_carbon_selectdisarmintent_down"
#define COMSIG_KB_CARBON_SELECTGRABINTENT_DOWN "keybinding_carbon_selectgrabintent_down"
#define COMSIG_KB_CARBON_SELECTHARMINTENT_DOWN "keybinding_carbon_selectharmintent_down"
#define COMSIG_KB_CARBON_HOLDTHROWMODE_DOWN "keybinding_carbon_holdthrowmode_down"
#define COMSIG_KB_CARBON_GIVEITEM_DOWN "keybinding_carbon_giveitem_down"

//Client
Expand Down
5 changes: 5 additions & 0 deletions code/__DEFINES/mobs.dm
Expand Up @@ -435,3 +435,8 @@
#define BODY_SIZE_NORMAL 1
#define BODY_SIZE_SHORT 0.93
#define BODY_SIZE_TALL 1.03

/// 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
8 changes: 5 additions & 3 deletions code/_onclick/click.dm
Expand Up @@ -118,11 +118,13 @@
RestrainedClickOn(A)
return

if(in_throw_mode && throw_item(A))
return

var/obj/item/W = get_active_held_item()

if(throw_mode && W)
changeNext_move(CLICK_CD_THROW)
throw_item(A)
return

Comment on lines -121 to +127
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broke logic

if(W == A)
W.attack_self(src)
update_inv_hands()
Expand Down
25 changes: 23 additions & 2 deletions code/datums/keybinding/carbon.dm
Expand Up @@ -89,6 +89,27 @@
user.mob?.a_intent_change(INTENT_HARM)
return TRUE

/datum/keybinding/carbon/hold_throw_mode
key = "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
ivanmixo marked this conversation as resolved.
Show resolved Hide resolved
carbon_user.throw_mode_off(THROW_MODE_HOLD)
/datum/keybinding/carbon/give
key = "G"
name = "Give_Item"
Expand All @@ -101,6 +122,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
4 changes: 2 additions & 2 deletions code/game/gamemodes/clown_ops/clown_weapons.dm
Expand Up @@ -163,7 +163,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)
Expand Down Expand Up @@ -202,7 +202,7 @@
if(iscarbon(loc))
to_chat(loc, "[src] begins to beep.")
var/mob/living/carbon/C = loc
C.throw_mode_on()
C.throw_mode_on(THROW_MODE_TOGGLE)
bomb.preprime(loc, null, FALSE)

/obj/item/grown/bananapeel/bombanana/ComponentInitialize()
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/melee/misc.dm
Expand Up @@ -703,7 +703,7 @@
to_chat(user, "<span class='notice'>You yank [I] towards yourself.</span>")
log_combat(user, target, "disarmed", src)
if(!user.get_inactive_held_item())
user.throw_mode_on()
user.throw_mode_on(THROW_MODE_TOGGLE)
user.swap_hand()
I.throw_at(user, 10, 2)

Expand Down
6 changes: 3 additions & 3 deletions code/modules/antagonists/changeling/powers/mutations.dm
Expand Up @@ -310,8 +310,8 @@
..()

/obj/item/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/item/projectile/tentacle/proc/tentacle_grab(mob/living/carbon/human/H, mob/living/carbon/C)
if(H.Adjacent(C))
Expand Down Expand Up @@ -341,7 +341,7 @@
var/obj/item/I = target
if(!I.anchored)
to_chat(firer, "<span class='notice'>You pull [I] towards yourself.</span>")
H.throw_mode_on()
H.throw_mode_on(THROW_MODE_TOGGLE)
I.throw_at(H, 10, 2)
. = BULLET_ACT_HIT

Expand Down
6 changes: 5 additions & 1 deletion code/modules/client/preferences_savefile.dm
Expand Up @@ -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 36
#define SAVEFILE_VERSION_MAX 37

/*
SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn
Expand Down Expand Up @@ -75,6 +75,10 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
//so im doing that
key_bindings += list("W" = list("move_north"), "A" = list("move_west"), "S" = list("move_south"), "D" = list("move_east"))
WRITE_FILE(S["key_bindings"], key_bindings)
if(current_version < 37)
key_bindings = S["key_bindings"]
key_bindings += list("Space" = list("hold_throw_mode"))
WRITE_FILE(S["key_bindings"], key_bindings)
return

/datum/preferences/proc/update_character(current_version, savefile/S)
Expand Down
3 changes: 0 additions & 3 deletions code/modules/hydroponics/grown/citrus.dm
Expand Up @@ -117,9 +117,6 @@
/obj/item/reagent_containers/food/snacks/grown/firelemon/attack_self(mob/living/user)
user.visible_message("<span class='warning'>[user] primes [src]!</span>", "<span class='userdanger'>You prime [src]!</span>")
log_bomber(user, "primed a", src, "for detonation")
if(iscarbon(user))
var/mob/living/carbon/C = user
C.throw_mode_on()
Comment on lines -120 to -122
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing this? When you prime a grenade, throw mode should be entered.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhh, no this is specific to this fruit for whatever reason. Regular grenades don't toggle your throw mode, so it's for consistency's sake.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regular grenades can be thrown while primed, even if not in throw mode.

icon_state = "firelemon_active"
playsound(loc, 'sound/weapons/armbomb.ogg', 75, 1, -3)
addtimer(CALLBACK(src, .proc/prime), rand(10, 60))
Expand Down
8 changes: 4 additions & 4 deletions code/modules/keybindings/bindings_client.dm
Expand Up @@ -65,8 +65,8 @@ GLOBAL_LIST_INIT(valid_keys, list(
var/datum/keybinding/kb = GLOB.keybindings_by_name[kb_name]
kbs += kb
kbs = sortList(kbs, /proc/cmp_keybinding_dsc)
for (var/datum/keybinding/kb in kbs)
if (kb.can_use(src) && kb.down(src))
for(var/datum/keybinding/kb in kbs)
if(kb.can_use(src) && kb.down(src))
break

if(holder)
Expand All @@ -93,8 +93,8 @@ GLOBAL_LIST_INIT(valid_keys, list(
var/datum/keybinding/kb = GLOB.keybindings_by_name[kb_name]
kbs += kb
kbs = sortList(kbs, /proc/cmp_keybinding_dsc)
for (var/datum/keybinding/kb in kbs)
if (kb.up(src))
for(var/datum/keybinding/kb in kbs)
if(kb.can_use(src) && kb.up(src))
break

if(holder)
Expand Down
22 changes: 12 additions & 10 deletions code/modules/mob/living/carbon/carbon.dm
Expand Up @@ -80,8 +80,8 @@
visible_message("<span class='danger'>[victim] catches [src]!</span>",\
"<span class='userdanger'>[victim] catches you!</span>")
grabbedby(victim, TRUE)
victim.throw_mode_off()
log_combat(victim, src, "caught (thrown mob)")
victim.throw_mode_off(THROW_MODE_TOGGLE)
log_combat(victim, src, "caught [src]")
return
if(hurt)
victim.take_bodypart_damage(10,check_armor = TRUE)
Expand Down Expand Up @@ -109,20 +109,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 = 0
/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(client && hud_used)
hud_used.throw_icon.icon_state = "act_throw_off"


/mob/living/carbon/proc/throw_mode_on()
in_throw_mode = 1
/mob/living/carbon/proc/throw_mode_on(mode = THROW_MODE_TOGGLE)
throw_mode = mode
if(client && hud_used)
hud_used.throw_icon.icon_state = "act_throw_on"

Expand All @@ -133,7 +135,7 @@

/mob/living/carbon/throw_item(atom/target)
. = ..()
throw_mode_off()
throw_mode_off(THROW_MODE_TOGGLE)
if(!target || !isturf(loc))
return FALSE
if(istype(target, /atom/movable/screen))
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/carbon/carbon_defense.dm
Expand Up @@ -45,7 +45,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
Expand All @@ -65,7 +65,7 @@
if(get_active_held_item() == I) //if our attack_hand() picks up the item...
visible_message("<span class='warning'>[src] catches [I]!</span>", \
"<span class='userdanger'>You catch [I] in mid-air!</span>")
throw_mode_off()
throw_mode_off(THROW_MODE_TOGGLE)
return 1
..(AM, skipcatch, hitpush, blocked, throwingdatum)

Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/human_defense.dm
Expand Up @@ -127,7 +127,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

Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/mob_defines.dm
Expand Up @@ -145,7 +145,7 @@
var/research_scanner = FALSE

/// Is the mob throw intent on
var/in_throw_mode = 0
var/throw_mode = THROW_MODE_DISABLED

/// What job does this mob have
var/job = null//Living
Expand Down
2 changes: 1 addition & 1 deletion code/modules/ninja/suit/n_suit_verbs/ninja_stars.dm
Expand Up @@ -9,7 +9,7 @@
to_chat(H, "<span class='notice'>A throwing star has been created in your hand!</span>")
else
qdel(N)
H.throw_mode_on() //So they can quickly throw it.
H.throw_mode_on(THROW_MODE_TOGGLE) //So they can quickly throw it.


/obj/item/throwing_star/ninja
Expand Down
2 changes: 1 addition & 1 deletion code/modules/paperwork/paperplane.dm
Expand Up @@ -62,7 +62,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
Expand Down
2 changes: 1 addition & 1 deletion code/modules/spells/spell_types/wizard.dm
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/surgery/organs/vocal_cords.dm
Expand Up @@ -465,7 +465,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)))
Expand Down