diff --git a/code/game/objects/items/weapons/stunbaton.dm b/code/game/objects/items/weapons/stunbaton.dm index ab5a5ba5349e..a8115cc2f4a7 100644 --- a/code/game/objects/items/weapons/stunbaton.dm +++ b/code/game/objects/items/weapons/stunbaton.dm @@ -66,6 +66,7 @@ icon_state = "[base_icon]_nocell" else icon_state = "[base_icon]" + /obj/item/melee/baton/examine(mob/user) . = ..() if(isrobot(user)) @@ -158,6 +159,10 @@ update_icon() add_fingerprint(user) +/obj/item/melee/baton/throw_impact(mob/living/carbon/human/hit_mob) + . = ..() + if(!. && turned_on && istype(hit_mob)) + thrown_baton_stun(hit_mob) /obj/item/melee/baton/attack(mob/M, mob/living/user) if(turned_on && HAS_TRAIT(user, TRAIT_CLUMSY) && prob(50)) @@ -224,6 +229,42 @@ deductcharge(hitcost) return TRUE +/obj/item/melee/baton/proc/thrown_baton_stun(mob/living/carbon/human/L) + if(cooldown > world.time) + return FALSE + + var/user_UID = thrownby + var/mob/user = locateUID(thrownby) + if(!istype(user) || (user.mind?.martial_art?.no_baton && user.mind?.martial_art?.can_use(user))) + return + + if(HAS_TRAIT_FROM(L, TRAIT_WAS_BATONNED, user_UID)) + return FALSE + + cooldown = world.time + initial(cooldown) + if(L.check_shields(src, 0, "[user]'s [name]", MELEE_ATTACK)) + playsound(L, 'sound/weapons/genhit.ogg', 50, TRUE) + return FALSE + L.Confused(4 SECONDS) + L.Jitter(4 SECONDS) + L.adjustStaminaLoss(30) + L.SetStuttering(4 SECONDS) + + ADD_TRAIT(L, TRAIT_WAS_BATONNED, user_UID) // so one person cannot hit the same person with two separate batons + L.apply_status_effect(STATUS_EFFECT_DELAYED, 2 SECONDS, CALLBACK(L, TYPE_PROC_REF(/mob/living, KnockDown), knockdown_duration), COMSIG_LIVING_CLEAR_STUNS) + addtimer(CALLBACK(src, PROC_REF(baton_delay), L, user_UID), 2 SECONDS) + + SEND_SIGNAL(L, COMSIG_LIVING_MINOR_SHOCK, 33) + + L.lastattacker = user.real_name + L.lastattackerckey = user.ckey + L.visible_message("[user] has stunned [L] with [src]!", + "[L == user ? "You stun yourself" : "[user] has stunned you"] with [src]!") + add_attack_logs(user, L, "stunned") + playsound(src, 'sound/weapons/egloves.ogg', 50, TRUE, -1) + deductcharge(hitcost) + return TRUE + /obj/item/melee/baton/proc/baton_delay(mob/living/target, user_UID) REMOVE_TRAIT(target, TRAIT_WAS_BATONNED, user_UID)