From b9e44c869e5c38ec1289aa88367eca79b750b974 Mon Sep 17 00:00:00 2001 From: mochi Date: Mon, 3 Aug 2020 22:38:16 +0200 Subject: [PATCH] Baton knockdown animation, refactor & doc --- code/game/objects/items/weapons/batons.dm | 127 ++++++++++++++++++ .../objects/items/weapons/swords_axes_etc.dm | 119 ---------------- code/game/objects/items/weapons/weaponry.dm | 9 +- paradise.dme | 2 +- 4 files changed, 136 insertions(+), 121 deletions(-) create mode 100644 code/game/objects/items/weapons/batons.dm delete mode 100644 code/game/objects/items/weapons/swords_axes_etc.dm diff --git a/code/game/objects/items/weapons/batons.dm b/code/game/objects/items/weapons/batons.dm new file mode 100644 index 00000000000..078ec21df92 --- /dev/null +++ b/code/game/objects/items/weapons/batons.dm @@ -0,0 +1,127 @@ +/// Delay in deci-seconds between two non-lethal attacks +#define BATON_STUN_COOLDOWN 4 SECONDS +/// Force of the telescopic baton when deployed +#define BATON_TELESCOPIC_FORCE_DEPLOYED 10 + +/** + * # Police Baton + * + * Knocks down the hit mob when not on harm intent and when [/obj/item/melee/classic_baton/on] is TRUE + * + * A non-lethal attack has a cooldown to avoid spamming + */ +/obj/item/melee/classic_baton + name = "police baton" + desc = "A wooden truncheon for beating criminal scum." + icon_state = "baton" + item_state = "classic_baton" + slot_flags = SLOT_BELT + force = 12 //9 hit crit + w_class = WEIGHT_CLASS_NORMAL + /// Whether the baton is on cooldown + var/on_cooldown = FALSE + /// Whether the baton is toggled on (to allow attacking) + var/on = TRUE + +/obj/item/melee/classic_baton/attack(mob/target, mob/living/user) + if(!on) + return ..() + + add_fingerprint(user) + if((CLUMSY in user.mutations) && prob(50)) + user.visible_message("[user] accidentally clubs [user.p_them()]self with [src]!", \ + "You accidentally club yourself with [src]!") + user.Weaken(force * 3) + if(ishuman(user)) + var/mob/living/carbon/human/H = user + H.apply_damage(force * 2, BRUTE, "head") + else + user.take_organ_damage(force * 2) + return + if(isrobot(target)) + return ..() + if(!isliving(target)) + return + + if(user.a_intent == INTENT_HARM) // Lethal attack + if(!..() || !isrobot(target)) + return + else if(!on_cooldown) // Non-lethal attack - knock them down + // Check for shield/countering + if(ishuman(target)) + var/mob/living/carbon/human/H = target + if(H.check_shields(src, 0, "[user]'s [name]", MELEE_ATTACK)) + return + if(check_martial_counter(H, user)) + return + // Visuals and sound + user.do_attack_animation(target) + playsound(target, 'sound/effects/woodhit.ogg', 75, TRUE, -1) + add_attack_logs(user, target, "Stunned with [src]") + target.visible_message("[user] has knocked down [target] with \the [src]!", \ + "[user] has knocked down [target] with \the [src]!") + // Hit 'em + target.LAssailant = iscarbon(user) ? user : null + target.Weaken(3) + on_cooldown = TRUE + addtimer(CALLBACK(src, .proc/cooldown_finished), BATON_STUN_COOLDOWN) + +/** + * Called some time after a non-lethal attack + */ +/obj/item/melee/classic_baton/proc/cooldown_finished() + on_cooldown = FALSE + +/** + * # Fancy Cane + */ +/obj/item/melee/classic_baton/ntcane + name = "fancy cane" + desc = "A cane with special engraving on it. It seems well suited for fending off assailants..." + icon_state = "cane_nt" + item_state = "cane_nt" + needs_permit = FALSE + +/obj/item/melee/classic_baton/ntcane/is_crutch() + return TRUE + +/** + * # Telescopic Baton + */ +/obj/item/melee/classic_baton/telescopic + name = "telescopic baton" + desc = "A compact yet robust personal defense weapon. Can be concealed when folded." + icon_state = "telebaton_0" + item_state = null + slot_flags = SLOT_BELT + w_class = WEIGHT_CLASS_SMALL + needs_permit = FALSE + force = 0 + on = FALSE + +/obj/item/melee/classic_baton/telescopic/attack_self(mob/user) + on = !on + icon_state = "telebaton_[on]" + if(on) + to_chat(user, "You extend the baton.") + item_state = "nullrod" + w_class = WEIGHT_CLASS_BULKY //doesnt fit in backpack when its on for balance + force = BATON_TELESCOPIC_FORCE_DEPLOYED //stunbaton damage + attack_verb = list("smacked", "struck", "cracked", "beaten") + else + to_chat(user, "You collapse the baton.") + item_state = null //no sprite for concealment even when in hand + slot_flags = SLOT_BELT + w_class = WEIGHT_CLASS_SMALL + force = 0 //not so robust now + attack_verb = list("hit", "poked") + // Update mob hand visuals + if(ishuman(user)) + var/mob/living/carbon/human/H = user + H.update_inv_l_hand() + H.update_inv_r_hand() + playsound(loc, 'sound/weapons/batonextend.ogg', 50, TRUE) + add_fingerprint(user) + +#undef BATON_STUN_COOLDOWN +#undef BATON_TELESCOPIC_FORCE_DEPLOYED diff --git a/code/game/objects/items/weapons/swords_axes_etc.dm b/code/game/objects/items/weapons/swords_axes_etc.dm deleted file mode 100644 index e75935a3cc2..00000000000 --- a/code/game/objects/items/weapons/swords_axes_etc.dm +++ /dev/null @@ -1,119 +0,0 @@ -/* Weapons - * Contains: - * Banhammer - * Classic Baton - */ - -/* - * Banhammer - */ -/obj/item/banhammer/attack(mob/M, mob/user) - to_chat(M, " You have been banned FOR NO REISIN by [user]") - to_chat(user, " You have BANNED [M]") - playsound(loc, 'sound/effects/adminhelp.ogg', 15) //keep it at 15% volume so people don't jump out of their skin too much - -/* - * Classic Baton - */ - -/obj/item/melee/classic_baton - name = "police baton" - desc = "A wooden truncheon for beating criminal scum." - icon_state = "baton" - item_state = "classic_baton" - slot_flags = SLOT_BELT - force = 12 //9 hit crit - w_class = WEIGHT_CLASS_NORMAL - var/cooldown = 0 - var/on = 1 - -/obj/item/melee/classic_baton/attack(mob/target as mob, mob/living/user as mob) - if(on) - add_fingerprint(user) - if((CLUMSY in user.mutations) && prob(50)) - to_chat(user, "You club yourself over the head.") - user.Weaken(3 * force) - if(ishuman(user)) - var/mob/living/carbon/human/H = user - H.apply_damage(2*force, BRUTE, "head") - else - user.take_organ_damage(2*force) - return - if(isrobot(target)) - ..() - return - if(!isliving(target)) - return - if(user.a_intent == INTENT_HARM) - if(!..()) return - if(!isrobot(target)) return - else - if(cooldown <= 0) - if(ishuman(target)) - var/mob/living/carbon/human/H = target - if(H.check_shields(src, 0, "[user]'s [name]", MELEE_ATTACK)) - return - if(check_martial_counter(H, user)) - return - playsound(get_turf(src), 'sound/effects/woodhit.ogg', 75, 1, -1) - target.Weaken(3) - add_attack_logs(user, target, "Stunned with [src]") - add_fingerprint(user) - target.visible_message("[user] has knocked down [target] with \the [src]!", \ - "[user] has knocked down [target] with \the [src]!") - if(!iscarbon(user)) - target.LAssailant = null - else - target.LAssailant = user - cooldown = 1 - spawn(40) - cooldown = 0 - return - else - return ..() - -/obj/item/melee/classic_baton/ntcane - name = "fancy cane" - desc = "A cane with special engraving on it. It seems well suited for fending off assailants..." - icon_state = "cane_nt" - item_state = "cane_nt" - needs_permit = 0 - -/obj/item/melee/classic_baton/ntcane/is_crutch() - return 1 - -//Telescopic baton -/obj/item/melee/classic_baton/telescopic - name = "telescopic baton" - desc = "A compact yet robust personal defense weapon. Can be concealed when folded." - icon_state = "telebaton_0" - item_state = null - slot_flags = SLOT_BELT - w_class = WEIGHT_CLASS_SMALL - needs_permit = 0 - force = 0 - on = 0 - -/obj/item/melee/classic_baton/telescopic/attack_self(mob/user as mob) - on = !on - if(on) - to_chat(user, "You extend the baton.") - icon_state = "telebaton_1" - item_state = "nullrod" - w_class = WEIGHT_CLASS_BULKY //doesnt fit in backpack when its on for balance - force = 10 //stunbaton damage - attack_verb = list("smacked", "struck", "cracked", "beaten") - else - to_chat(user, "You collapse the baton.") - icon_state = "telebaton_0" - item_state = null //no sprite for concealment even when in hand - slot_flags = SLOT_BELT - w_class = WEIGHT_CLASS_SMALL - force = 0 //not so robust now - attack_verb = list("hit", "poked") - if(istype(user,/mob/living/carbon/human)) - var/mob/living/carbon/human/H = user - H.update_inv_l_hand() - H.update_inv_r_hand() - playsound(src.loc, 'sound/weapons/batonextend.ogg', 50, 1) - add_fingerprint(user) diff --git a/code/game/objects/items/weapons/weaponry.dm b/code/game/objects/items/weapons/weaponry.dm index 32158a9a3ab..e5f903a1853 100644 --- a/code/game/objects/items/weapons/weaponry.dm +++ b/code/game/objects/items/weapons/weaponry.dm @@ -1,3 +1,6 @@ +/** + * # Banhammer + */ /obj/item/banhammer desc = "A banhammer" name = "banhammer" @@ -13,11 +16,15 @@ armor = list("melee" = 0, "bullet" = 0, "laser" = 0, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 100, "acid" = 70) resistance_flags = FIRE_PROOF - /obj/item/banhammer/suicide_act(mob/user) to_chat(viewers(user), "[user] is hitting [user.p_them()]self with the [src.name]! It looks like [user.p_theyre()] trying to ban [user.p_them()]self from life.") return BRUTELOSS|FIRELOSS|TOXLOSS|OXYLOSS +/obj/item/banhammer/attack(mob/M, mob/user) + to_chat(M, " You have been banned FOR NO REISIN by [user]") + to_chat(user, " You have BANNED [M]") + playsound(loc, 'sound/effects/adminhelp.ogg', 15) //keep it at 15% volume so people don't jump out of their skin too much + /obj/item/sord name = "\improper SORD" desc = "This thing is so unspeakably shitty you are having a hard time even holding it." diff --git a/paradise.dme b/paradise.dme index b59a1d75541..5acf3b830d1 100644 --- a/paradise.dme +++ b/paradise.dme @@ -940,6 +940,7 @@ #include "code\game\objects\items\tools\wrench.dm" #include "code\game\objects\items\weapons\AI_modules.dm" #include "code\game\objects\items\weapons\alien_specific.dm" +#include "code\game\objects\items\weapons\batons.dm" #include "code\game\objects\items\weapons\bee_briefcase.dm" #include "code\game\objects\items\weapons\cards_ids.dm" #include "code\game\objects\items\weapons\cash.dm" @@ -988,7 +989,6 @@ #include "code\game\objects\items\weapons\staff.dm" #include "code\game\objects\items\weapons\stock_parts.dm" #include "code\game\objects\items\weapons\stunbaton.dm" -#include "code\game\objects\items\weapons\swords_axes_etc.dm" #include "code\game\objects\items\weapons\tape.dm" #include "code\game\objects\items\weapons\teleportation.dm" #include "code\game\objects\items\weapons\teleprod.dm"