From 1ef93fe73e2b469059f0db3ca86497e9e2ac4b64 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Sat, 4 Jun 2022 17:46:14 +0100 Subject: [PATCH 01/14] Update stunbaton.dm --- code/game/objects/items/stunbaton.dm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 518d3f429696..32212f397ce0 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -15,7 +15,7 @@ armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 50, BIO = 0, RAD = 0, FIRE = 80, ACID = 80) var/cooldown_check = 0 - + var/dropcheck = FALSE ///how long we can't use this baton for after slapping someone with it. Does not account for melee attack cooldown (default of 0.8 seconds). var/cooldown = 1.2 SECONDS ///how long a clown stuns themself for, or someone is stunned for if they are hit to >90 stamina damage @@ -58,6 +58,16 @@ if(status && prob(throw_hit_chance) && iscarbon(hit_atom)) baton_stun(hit_atom) +/obj/item/melee/baton/dropped(mob/user, silent) + . = ..() + status = FALSE + dropcheck = TRUE + addtimer(CALLBACK(src, .proc/reclibrate), 8 SECONDS) + +/obj/item/baton/recalibrate() + dropcheck = FALSE + status = TRUE + /obj/item/melee/baton/loaded //this one starts with a cell pre-installed. preload_cell_type = /obj/item/stock_parts/cell/high @@ -124,6 +134,8 @@ return ..() /obj/item/melee/baton/attack_self(mob/user) + if(dropcheck == TRUE) + to_chat("Baton has been dropped and needs to recalibrate!") if(cell && cell.charge > hitcost) status = !status to_chat(user, span_notice("[src] is now [status ? "on" : "off"].")) From 90a6ae1477b24948128e13c59432b048ed213150 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Sat, 4 Jun 2022 17:49:31 +0100 Subject: [PATCH 02/14] e --- code/game/objects/items/stunbaton.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 32212f397ce0..12c4975064c9 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -64,7 +64,7 @@ dropcheck = TRUE addtimer(CALLBACK(src, .proc/reclibrate), 8 SECONDS) -/obj/item/baton/recalibrate() +/obj/item/baton/proc/recalibrate() dropcheck = FALSE status = TRUE From bd82a318a487fd17019c47b5418a4019c74ccc90 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Sat, 4 Jun 2022 17:51:47 +0100 Subject: [PATCH 03/14] e2 --- code/game/objects/items/stunbaton.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 12c4975064c9..6c09bd42e160 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -62,7 +62,7 @@ . = ..() status = FALSE dropcheck = TRUE - addtimer(CALLBACK(src, .proc/reclibrate), 8 SECONDS) + addtimer(CALLBACK(src, .proc/recalibrate), 8 SECONDS) /obj/item/baton/proc/recalibrate() dropcheck = FALSE From 3a0631fdccfd30594ad280354e9339a842926d1d Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Sat, 4 Jun 2022 18:01:56 +0100 Subject: [PATCH 04/14] e --- code/game/objects/items/stunbaton.dm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 6c09bd42e160..5d31189637f1 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -60,13 +60,16 @@ /obj/item/melee/baton/dropped(mob/user, silent) . = ..() - status = FALSE - dropcheck = TRUE + visible_message(span_warning("The safety strap on [src] is pulled as it is dropped, triggering its emergency shutoff!")) addtimer(CALLBACK(src, .proc/recalibrate), 8 SECONDS) -/obj/item/baton/proc/recalibrate() +/obj/item/melee/baton/proc/recalibrate() dropcheck = FALSE status = TRUE + playsound(loc, "sparks", 75, 1, -1) + cell_last_used = 0 + START_PROCESSING(SSobj, src) + update_icon() /obj/item/melee/baton/loaded //this one starts with a cell pre-installed. preload_cell_type = /obj/item/stock_parts/cell/high @@ -134,8 +137,8 @@ return ..() /obj/item/melee/baton/attack_self(mob/user) - if(dropcheck == TRUE) - to_chat("Baton has been dropped and needs to recalibrate!") + if(dropcheck) + to_chat("[src]'s emergency shutoff is still active!") if(cell && cell.charge > hitcost) status = !status to_chat(user, span_notice("[src] is now [status ? "on" : "off"].")) From e1e8904ce57b829b34b2ccabde333b5672a0f38f Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Sat, 4 Jun 2022 18:04:01 +0100 Subject: [PATCH 05/14] Update code/game/objects/items/stunbaton.dm Co-authored-by: Theos --- code/game/objects/items/stunbaton.dm | 1 + 1 file changed, 1 insertion(+) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 5d31189637f1..fccf526f5714 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -15,6 +15,7 @@ armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 50, BIO = 0, RAD = 0, FIRE = 80, ACID = 80) var/cooldown_check = 0 + /// if the baton is on cooldown from being dropped var/dropcheck = FALSE ///how long we can't use this baton for after slapping someone with it. Does not account for melee attack cooldown (default of 0.8 seconds). var/cooldown = 1.2 SECONDS From b88dfa2a0e583895dbf87403076b49967539ed49 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Sat, 4 Jun 2022 18:12:45 +0100 Subject: [PATCH 06/14] e3 --- code/game/objects/items/stunbaton.dm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 5d31189637f1..3f092b04999f 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -60,6 +60,8 @@ /obj/item/melee/baton/dropped(mob/user, silent) . = ..() + dropcheck = TRUE + status = FALSE visible_message(span_warning("The safety strap on [src] is pulled as it is dropped, triggering its emergency shutoff!")) addtimer(CALLBACK(src, .proc/recalibrate), 8 SECONDS) From a39b8e00cdd38145c9aa2c862f672d95cc574387 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Sat, 4 Jun 2022 20:45:22 +0100 Subject: [PATCH 07/14] e4 --- code/game/objects/items/stunbaton.dm | 1 + 1 file changed, 1 insertion(+) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index d50b00dd407f..cc5e2ebf6058 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -64,6 +64,7 @@ dropcheck = TRUE status = FALSE visible_message(span_warning("The safety strap on [src] is pulled as it is dropped, triggering its emergency shutoff!")) + update_icon() addtimer(CALLBACK(src, .proc/recalibrate), 8 SECONDS) /obj/item/melee/baton/proc/recalibrate() From 31cadcb1e82855ca1b021a3e415c2dfde3b584e1 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Sat, 4 Jun 2022 21:51:38 +0100 Subject: [PATCH 08/14] e5 --- code/game/objects/items/stunbaton.dm | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index cc5e2ebf6058..c00d6b0d3139 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -45,6 +45,7 @@ /obj/item/melee/baton/Initialize() . = ..() + status = FALSE if(preload_cell_type) if(!ispath(preload_cell_type,/obj/item/stock_parts/cell)) log_mapping("[src] at [AREACOORD(src)] had an invalid preload_cell_type: [preload_cell_type].") @@ -64,15 +65,7 @@ dropcheck = TRUE status = FALSE visible_message(span_warning("The safety strap on [src] is pulled as it is dropped, triggering its emergency shutoff!")) - update_icon() - addtimer(CALLBACK(src, .proc/recalibrate), 8 SECONDS) - -/obj/item/melee/baton/proc/recalibrate() - dropcheck = FALSE - status = TRUE - playsound(loc, "sparks", 75, 1, -1) - cell_last_used = 0 - START_PROCESSING(SSobj, src) + addtimer(VARSET_CALLBACK(src, dropcheck, FALSE), 8 SECONDS) update_icon() /obj/item/melee/baton/loaded //this one starts with a cell pre-installed. @@ -142,7 +135,8 @@ /obj/item/melee/baton/attack_self(mob/user) if(dropcheck) - to_chat("[src]'s emergency shutoff is still active!") + to_chat(users, "[src]'s emergency shutoff is still active!") + return if(cell && cell.charge > hitcost) status = !status to_chat(user, span_notice("[src] is now [status ? "on" : "off"].")) From 62646c383ce29270415d8c653feae184af2fd1a2 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Sat, 4 Jun 2022 21:53:37 +0100 Subject: [PATCH 09/14] e6 --- code/game/objects/items/stunbaton.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index c00d6b0d3139..f90f0c4c1e3c 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -135,7 +135,7 @@ /obj/item/melee/baton/attack_self(mob/user) if(dropcheck) - to_chat(users, "[src]'s emergency shutoff is still active!") + to_chat(user, "[src]'s emergency shutoff is still active!") return if(cell && cell.charge > hitcost) status = !status From f294801dc0a93f14efb6178d4e0a9cfb633a66d6 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Sat, 4 Jun 2022 23:06:58 +0100 Subject: [PATCH 10/14] SKETCHY CODE --- code/game/objects/items/stunbaton.dm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index f90f0c4c1e3c..7fd62741871a 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -61,6 +61,8 @@ baton_stun(hit_atom) /obj/item/melee/baton/dropped(mob/user, silent) + if(z == 0) + return . = ..() dropcheck = TRUE status = FALSE From dbc7ec97df4d62c6086d7ce5f0fa00c11f722b87 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Tue, 7 Jun 2022 23:48:37 +0100 Subject: [PATCH 11/14] Fixes throw with some Jank --- code/__DEFINES/components.dm | 1 + code/game/objects/items/stunbaton.dm | 20 ++++++++++++++------ code/modules/mob/living/carbon/carbon.dm | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/code/__DEFINES/components.dm b/code/__DEFINES/components.dm index 9d0ca1711f5f..388f311437b3 100644 --- a/code/__DEFINES/components.dm +++ b/code/__DEFINES/components.dm @@ -156,6 +156,7 @@ #define COMSIG_MOVABLE_BUCKLE "buckle" //from base of atom/movable/buckle_mob(): (mob, force) #define COMSIG_MOVABLE_UNBUCKLE "unbuckle" //from base of atom/movable/unbuckle_mob(): (mob, force) #define COMSIG_MOVABLE_PRE_THROW "movable_pre_throw" //from base of atom/movable/throw_at(): (list/args) +#define COMSIG_MOVABLE_PRE_DROPTHROW "movable_pre_dropthrow" //from base of atom/movable/throw_at(): (list/args) #define COMPONENT_CANCEL_THROW 1 #define COMSIG_MOVABLE_POST_THROW "movable_post_throw" //from base of atom/movable/throw_at(): (datum/thrownthing, spin) #define COMSIG_MOVABLE_Z_CHANGED "movable_ztransit" //from base of atom/movable/onTransitZ(): (old_z, new_z) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 7fd62741871a..8ce45483046e 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -35,6 +35,7 @@ var/preload_cell_type ///used for passive discharge var/cell_last_used = 0 + var/thrown = FALSE /obj/item/melee/baton/get_cell() return cell @@ -51,6 +52,7 @@ log_mapping("[src] at [AREACOORD(src)] had an invalid preload_cell_type: [preload_cell_type].") else cell = new preload_cell_type(src) + RegisterSignal(src, COMSIG_MOVABLE_PRE_DROPTHROW, .proc/throwbaton) update_icon() /obj/item/melee/baton/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) @@ -60,15 +62,21 @@ if(status && prob(throw_hit_chance) && iscarbon(hit_atom)) baton_stun(hit_atom) +/obj/item/melee/baton/proc/throwbaton() + thrown = TRUE + /obj/item/melee/baton/dropped(mob/user, silent) - if(z == 0) + if(loc != user.loc) return . = ..() - dropcheck = TRUE - status = FALSE - visible_message(span_warning("The safety strap on [src] is pulled as it is dropped, triggering its emergency shutoff!")) - addtimer(VARSET_CALLBACK(src, dropcheck, FALSE), 8 SECONDS) - update_icon() + if(!thrown) + dropcheck = TRUE + status = FALSE + visible_message(span_warning("The safety strap on [src] is pulled as it is dropped, triggering its emergency shutoff!")) + addtimer(VARSET_CALLBACK(src, dropcheck, FALSE), 8 SECONDS) + update_icon() + else + thrown = FALSE /obj/item/melee/baton/loaded //this one starts with a cell pre-installed. preload_cell_type = /obj/item/stock_parts/cell/high diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 8234f746b9f1..5503177ca5ef 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -187,6 +187,7 @@ else if(!CHECK_BITFIELD(I.item_flags, ABSTRACT) && !HAS_TRAIT(I, TRAIT_NODROP)) thrown_thing = I + SEND_SIGNAL(thrown_thing, COMSIG_MOVABLE_PRE_DROPTHROW, src) dropItemToGround(I, silent = TRUE) if(HAS_TRAIT(src, TRAIT_PACIFISM) && I.throwforce) From 52fface2c7467ab0165f95a316d5121e3aa0b7a5 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Wed, 8 Jun 2022 00:04:06 +0100 Subject: [PATCH 12/14] Explanation --- code/__DEFINES/components.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/__DEFINES/components.dm b/code/__DEFINES/components.dm index 388f311437b3..22ae9cdf467b 100644 --- a/code/__DEFINES/components.dm +++ b/code/__DEFINES/components.dm @@ -156,7 +156,7 @@ #define COMSIG_MOVABLE_BUCKLE "buckle" //from base of atom/movable/buckle_mob(): (mob, force) #define COMSIG_MOVABLE_UNBUCKLE "unbuckle" //from base of atom/movable/unbuckle_mob(): (mob, force) #define COMSIG_MOVABLE_PRE_THROW "movable_pre_throw" //from base of atom/movable/throw_at(): (list/args) -#define COMSIG_MOVABLE_PRE_DROPTHROW "movable_pre_dropthrow" //from base of atom/movable/throw_at(): (list/args) +#define COMSIG_MOVABLE_PRE_DROPTHROW "movable_pre_dropthrow" //from base of atom/movable/throw_at(): Triggers before throw just before the item is dropped #define COMPONENT_CANCEL_THROW 1 #define COMSIG_MOVABLE_POST_THROW "movable_post_throw" //from base of atom/movable/throw_at(): (datum/thrownthing, spin) #define COMSIG_MOVABLE_Z_CHANGED "movable_ztransit" //from base of atom/movable/onTransitZ(): (old_z, new_z) From 54c12142df6745b0551bb5b64447790a989210f0 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Wed, 8 Jun 2022 00:09:04 +0100 Subject: [PATCH 13/14] wahhh --- code/__DEFINES/components.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/__DEFINES/components.dm b/code/__DEFINES/components.dm index 22ae9cdf467b..06f0c8a00272 100644 --- a/code/__DEFINES/components.dm +++ b/code/__DEFINES/components.dm @@ -155,8 +155,8 @@ #define COMSIG_MOVABLE_IMPACT_ZONE "item_impact_zone" //from base of mob/living/hitby(): (mob/living/target, hit_zone) #define COMSIG_MOVABLE_BUCKLE "buckle" //from base of atom/movable/buckle_mob(): (mob, force) #define COMSIG_MOVABLE_UNBUCKLE "unbuckle" //from base of atom/movable/unbuckle_mob(): (mob, force) +#define COMSIG_MOVABLE_PRE_DROPTHROW "movable_pre_dropthrow" //from base of atom/movable/throw_at(): Triggers before throw just before the item is dropped and before Pre Throw #define COMSIG_MOVABLE_PRE_THROW "movable_pre_throw" //from base of atom/movable/throw_at(): (list/args) -#define COMSIG_MOVABLE_PRE_DROPTHROW "movable_pre_dropthrow" //from base of atom/movable/throw_at(): Triggers before throw just before the item is dropped #define COMPONENT_CANCEL_THROW 1 #define COMSIG_MOVABLE_POST_THROW "movable_post_throw" //from base of atom/movable/throw_at(): (datum/thrownthing, spin) #define COMSIG_MOVABLE_Z_CHANGED "movable_ztransit" //from base of atom/movable/onTransitZ(): (old_z, new_z) From 30c4a94f8477c2bf041481826945a4424ccd53f9 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Wed, 8 Jun 2022 00:13:03 +0100 Subject: [PATCH 14/14] Update code/__DEFINES/components.dm Co-authored-by: Byemoh --- code/__DEFINES/components.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/__DEFINES/components.dm b/code/__DEFINES/components.dm index 06f0c8a00272..af625445a55d 100644 --- a/code/__DEFINES/components.dm +++ b/code/__DEFINES/components.dm @@ -155,7 +155,7 @@ #define COMSIG_MOVABLE_IMPACT_ZONE "item_impact_zone" //from base of mob/living/hitby(): (mob/living/target, hit_zone) #define COMSIG_MOVABLE_BUCKLE "buckle" //from base of atom/movable/buckle_mob(): (mob, force) #define COMSIG_MOVABLE_UNBUCKLE "unbuckle" //from base of atom/movable/unbuckle_mob(): (mob, force) -#define COMSIG_MOVABLE_PRE_DROPTHROW "movable_pre_dropthrow" //from base of atom/movable/throw_at(): Triggers before throw just before the item is dropped and before Pre Throw +#define COMSIG_MOVABLE_PRE_DROPTHROW "movable_pre_dropthrow" //from base of atom/movable/throw_at(): Triggers when throwing, before the item is dropped and before COMSIG_MOVABLE_PRE_THROW #define COMSIG_MOVABLE_PRE_THROW "movable_pre_throw" //from base of atom/movable/throw_at(): (list/args) #define COMPONENT_CANCEL_THROW 1 #define COMSIG_MOVABLE_POST_THROW "movable_post_throw" //from base of atom/movable/throw_at(): (datum/thrownthing, spin)