diff --git a/code/__DEFINES/components.dm b/code/__DEFINES/components.dm index 9d0ca1711f5f..af625445a55d 100644 --- a/code/__DEFINES/components.dm +++ b/code/__DEFINES/components.dm @@ -155,6 +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 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) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index b51c7ee06dab..824596960c55 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -15,7 +15,8 @@ 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 ///how long a clown stuns themself for, or someone is stunned for if they are hit to >90 stamina damage @@ -34,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 @@ -44,11 +46,13 @@ /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].") 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) @@ -58,6 +62,22 @@ 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(loc != user.loc) + return + . = ..() + 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 @@ -124,6 +144,9 @@ return ..() /obj/item/melee/baton/attack_self(mob/user) + if(dropcheck) + to_chat(user, "[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"].")) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index cf5cbd64b0ec..93dd3bb6e559 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)