From 6b127dc2cc5f6d5ac8384e6e8cddaec3ef16ead2 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Thu, 2 Jun 2022 20:49:16 +0100 Subject: [PATCH 1/9] Batons V2 --- code/game/objects/items/stunbaton.dm | 66 ++++++++++++++++++- .../research/designs/weapon_designs.dm | 10 +++ code/modules/research/techweb/all_nodes.dm | 2 +- 3 files changed, 75 insertions(+), 3 deletions(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index a7885dcac45c..89398223679c 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -34,6 +34,8 @@ var/preload_cell_type ///used for passive discharge var/cell_last_used = 0 + var/obj/item/firing_pin/pin = /obj/item/firing_pin + var/obj/item/batonupgrade/upgrade /obj/item/melee/baton/get_cell() return cell @@ -44,13 +46,26 @@ /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) + if(pin) + pin = new pin(src) update_icon() +/obj/item/melee/baton/Destroy() + . = ..() + if(isobj(pin)) //Can still be the initial path, then we skip + QDEL_NULL(pin) + +/obj/item/melee/baton/handle_atom_del(atom/A) + . = ..() + if(A == pin) + pin = null + /obj/item/melee/baton/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) if(..()) return @@ -110,7 +125,20 @@ cell = W to_chat(user, span_notice("You install a cell in [src].")) update_icon() - + else if(istype(W, /obj/item/firing_pin)) + if(pin) + to_chat(user, span_notice("[src] already has a firing pin. You can remove it with crowbar")) + else if(W.tool_behaviour == TOOL_CROWBAR) + if(pin) + pin.forceMove(get_turf(src)) + pin = null + status = FALSE + to_chat(user, span_notice("You remove the firing pin from [src].")) + if(upgrade) + upgrade.forceMove(get_turf(src)) + upgrade = null + status = FALSE + to_chat(user, span_notice("You remove the upgrade from [src].")) else if(W.tool_behaviour == TOOL_SCREWDRIVER) if(cell) cell.update_icon() @@ -124,6 +152,11 @@ return ..() /obj/item/melee/baton/attack_self(mob/user) + if(!pin) + to_chat("There is no firing pin installed!") + if(!handle_pins(user)) + to_chat(user, span_warning("You are not authorised to use [src].")) + return FALSE if(cell && cell.charge > hitcost) status = !status to_chat(user, span_notice("[src] is now [status ? "on" : "off"].")) @@ -143,6 +176,12 @@ add_fingerprint(user) /obj/item/melee/baton/attack(mob/M, mob/living/carbon/human/user) + if(!pin) + to_chat("There is no firing pin installed!") + return FALSE + if(!handle_pins(user)) + to_chat(user, span_warning("You are not authorised to use [src].")) + return FALSE if(status && HAS_TRAIT(user, TRAIT_CLUMSY) && prob(50)) user.visible_message(span_danger("[user] accidentally hits [user.p_them()]self with [src]!"), \ span_userdanger("You accidentally hit yourself with [src]!")) @@ -164,7 +203,6 @@ ..() return - if(ishuman(M)) var/mob/living/carbon/human/L = M var/datum/martial_art/A = L.check_block() @@ -191,6 +229,11 @@ /obj/item/melee/baton/proc/baton_stun(mob/living/L, mob/user) + if(upgrade) + stamina_damage = initial(stamina_damage)*2 + hitcost = initial(hitcost)*1.5 + else + stamina_damage = initial(stamina_damage) if(ishuman(L)) var/mob/living/carbon/human/H = L if(H.check_shields(src, 0, "[user]'s [name]", MELEE_ATTACK)) //No message; check_shields() handles that @@ -209,6 +252,8 @@ var/obj/item/bodypart/affecting = L.get_bodypart(user.zone_selected) var/armor_block = L.run_armor_check(affecting, ENERGY) //check armor on the limb because that's where we are slapping... L.apply_damage(stamina_damage, STAMINA, BODY_ZONE_CHEST, armor_block) //...then deal damage to chest so we can't do the old hit-a-disabled-limb-200-times thing, batons are electrical not directed. + + SEND_SIGNAL(L, COMSIG_LIVING_MINOR_SHOCK) var/current_stamina_damage = L.getStaminaLoss() @@ -283,3 +328,20 @@ desc = "A cost-effective, mass-produced, tactical stun prod." preload_cell_type = /obj/item/stock_parts/cell/high/plus // comes with a cell color = "#aeb08c" // super tactical + +/obj/item/melee/baton/proc/handle_pins(mob/living/user) + if(pin) + if(pin.pin_auth(user) || (pin.obj_flags & EMAGGED)) + return TRUE + else + pin.auth_fail(user) + return FALSE + else + to_chat(user, span_warning("[src]'s trigger is locked. This weapon doesn't have a firing pin installed!")) + return FALSE + +/obj/item/batonupgrade + name = "Baton power upgrade" + desc = "A new power management circuit which enables double the power drain to instant stun." + icon = 'icons/obj/module.dmi' + icon_state = "cyborg_upgrade3" diff --git a/code/modules/research/designs/weapon_designs.dm b/code/modules/research/designs/weapon_designs.dm index 379be0d487c1..90f35515dd1b 100644 --- a/code/modules/research/designs/weapon_designs.dm +++ b/code/modules/research/designs/weapon_designs.dm @@ -104,6 +104,16 @@ category = list("Firing Pins") departmental_flags = DEPARTMENTAL_FLAG_SECURITY +/datum/design/batonupgrade + name = "Baton Power Upgrade" + desc = "A new power management circuit which enables double the power drain to instant stun." + id = "baton_upgrade" + build_type = PROTOLATHE + materials = list(/datum/material/gold = 600, /datum/material/silver = 600, /datum/material/diamond = 600, /datum/material/uranium = 600, /datum/material/plasma = 600) + build_path = /obj/item/batonupgrade + category = list("Firing Pins") + departmental_flags = DEPARTMENTAL_FLAG_SECURITY + /datum/design/stunmine/sec //mines ported from BeeStation name = "Stun Mine" desc = "A basic non-lethal stunning mine. Stuns anyone who walks over it." diff --git a/code/modules/research/techweb/all_nodes.dm b/code/modules/research/techweb/all_nodes.dm index 45e579650cf1..1ad45b040ab8 100644 --- a/code/modules/research/techweb/all_nodes.dm +++ b/code/modules/research/techweb/all_nodes.dm @@ -686,7 +686,7 @@ display_name = "Advanced Weapon Development Technology" description = "Our weapons are breaking the rules of reality by now." prereq_ids = list("adv_engi", "weaponry") - design_ids = list("pin_loyalty", "borg_transform_security") + design_ids = list("pin_loyalty", "borg_transform_security", "baton_upgrade") research_costs = list(TECHWEB_POINT_TYPE_GENERIC = 10000) export_price = 5000 From 30d10b248b41f3cd964be2cd2ac54003248c9dda Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Thu, 2 Jun 2022 21:19:50 +0100 Subject: [PATCH 2/9] Fuck off bibby --- code/game/objects/items/stunbaton.dm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 89398223679c..2855f7286925 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -155,7 +155,6 @@ if(!pin) to_chat("There is no firing pin installed!") if(!handle_pins(user)) - to_chat(user, span_warning("You are not authorised to use [src].")) return FALSE if(cell && cell.charge > hitcost) status = !status @@ -176,11 +175,7 @@ add_fingerprint(user) /obj/item/melee/baton/attack(mob/M, mob/living/carbon/human/user) - if(!pin) - to_chat("There is no firing pin installed!") - return FALSE if(!handle_pins(user)) - to_chat(user, span_warning("You are not authorised to use [src].")) return FALSE if(status && HAS_TRAIT(user, TRAIT_CLUMSY) && prob(50)) user.visible_message(span_danger("[user] accidentally hits [user.p_them()]self with [src]!"), \ From 6da8d846e8fa37ec3f92bf4e2d80d2151bbb2bac Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Thu, 2 Jun 2022 21:32:56 +0100 Subject: [PATCH 3/9] e --- code/game/objects/items/stunbaton.dm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 2855f7286925..1b75577370d3 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -128,6 +128,15 @@ else if(istype(W, /obj/item/firing_pin)) if(pin) to_chat(user, span_notice("[src] already has a firing pin. You can remove it with crowbar")) + else + W.forceMove(src) + pin = W + else if(istype(W, upgrade)) + if(upgrade) + to_chat(user, span_notice("[src] already has an upgrade installed. You can remove it with crowbar")) + else + W.forceMove(src) + upgrade = W else if(W.tool_behaviour == TOOL_CROWBAR) if(pin) pin.forceMove(get_turf(src)) From 57098007ab12e04957205de378ff91fb4107f3d2 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Thu, 2 Jun 2022 21:59:06 +0100 Subject: [PATCH 4/9] OR now --- code/game/objects/items/stunbaton.dm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 1b75577370d3..10b1f1c62ce9 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -126,12 +126,20 @@ to_chat(user, span_notice("You install a cell in [src].")) update_icon() else if(istype(W, /obj/item/firing_pin)) + if(upgrade) + if(W.type != /obj/item/firing_pin) + to_chat("You are unable to add a non default firing pin whilst it has an upgrade, remove it first with a crowbar") + return if(pin) to_chat(user, span_notice("[src] already has a firing pin. You can remove it with crowbar")) else W.forceMove(src) pin = W else if(istype(W, upgrade)) + if(pin) + if(pin.type != /obj/item/firing_pin) + to_chat("You are unable to upgrade the baton whilst it has a non default pin") + return if(upgrade) to_chat(user, span_notice("[src] already has an upgrade installed. You can remove it with crowbar")) else From 8bf0a409dfe0d007d77dfcd49ce09008fcdfeb21 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Thu, 2 Jun 2022 22:00:13 +0100 Subject: [PATCH 5/9] fixes status --- code/game/objects/items/stunbaton.dm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 10b1f1c62ce9..126d8776a315 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -23,7 +23,7 @@ ///how much stamina damage we deal per hit, this is combatted by energy armor var/stamina_damage = 70 ///are we turned on - var/status = TRUE + var/status = FALSE ///the cell used by the baton var/obj/item/stock_parts/cell/cell ///how much charge is deducted from the cell when we slap someone while on @@ -46,7 +46,6 @@ /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].") From 5f830671241769d6a6d0de7028dd81295365151c Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Thu, 2 Jun 2022 22:03:03 +0100 Subject: [PATCH 6/9] 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 126d8776a315..f2a8a26f8c85 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -162,8 +162,8 @@ cell = null to_chat(user, span_notice("You remove the cell from [src].")) status = FALSE - update_icon() STOP_PROCESSING(SSobj, src) // no cell, no charge; stop processing for on because it cant be on + update_icon() else return ..() From 8a8ee389290f7e88f4481fb5c5d70a2faf238d56 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Thu, 2 Jun 2022 22:12:12 +0100 Subject: [PATCH 7/9] e --- code/game/objects/items/stunbaton.dm | 27 +++++++++++++------ .../research/designs/weapon_designs.dm | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index f2a8a26f8c85..a631622c0aa2 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -34,6 +34,7 @@ var/preload_cell_type ///used for passive discharge var/cell_last_used = 0 + var/makeshift = FALSE var/obj/item/firing_pin/pin = /obj/item/firing_pin var/obj/item/batonupgrade/upgrade @@ -59,11 +60,15 @@ . = ..() if(isobj(pin)) //Can still be the initial path, then we skip QDEL_NULL(pin) + if(isobj(upgrade)) //Can still be the initial path, then we skip + QDEL_NULL(upgrade) /obj/item/melee/baton/handle_atom_del(atom/A) . = ..() if(A == pin) pin = null + if(A == upgrade) + upgrade = null /obj/item/melee/baton/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) if(..()) @@ -125,19 +130,23 @@ to_chat(user, span_notice("You install a cell in [src].")) update_icon() else if(istype(W, /obj/item/firing_pin)) + if(makeshift == TRUE) + return if(upgrade) if(W.type != /obj/item/firing_pin) - to_chat("You are unable to add a non default firing pin whilst it has an upgrade, remove it first with a crowbar") + to_chat("You are unable to add a non default firing pin whilst [src] has an upgrade. Remove the upgrade first with a crowbar.") return if(pin) - to_chat(user, span_notice("[src] already has a firing pin. You can remove it with crowbar")) + to_chat(user, span_notice("[src] already has a firing pin. You can remove it with crowbar.")) else W.forceMove(src) pin = W else if(istype(W, upgrade)) + if(makeshift == TRUE) + return if(pin) if(pin.type != /obj/item/firing_pin) - to_chat("You are unable to upgrade the baton whilst it has a non default pin") + to_chat("You are unable to upgrade the baton whilst it has a non default firing pin.") return if(upgrade) to_chat(user, span_notice("[src] already has an upgrade installed. You can remove it with crowbar")) @@ -145,6 +154,8 @@ W.forceMove(src) upgrade = W else if(W.tool_behaviour == TOOL_CROWBAR) + if(makeshift == TRUE) + return if(pin) pin.forceMove(get_turf(src)) pin = null @@ -155,6 +166,7 @@ upgrade = null status = FALSE to_chat(user, span_notice("You remove the upgrade from [src].")) + update_icon() else if(W.tool_behaviour == TOOL_SCREWDRIVER) if(cell) cell.update_icon() @@ -163,13 +175,11 @@ to_chat(user, span_notice("You remove the cell from [src].")) status = FALSE STOP_PROCESSING(SSobj, src) // no cell, no charge; stop processing for on because it cant be on - update_icon() + update_icon() else return ..() /obj/item/melee/baton/attack_self(mob/user) - if(!pin) - to_chat("There is no firing pin installed!") if(!handle_pins(user)) return FALSE if(cell && cell.charge > hitcost) @@ -324,6 +334,7 @@ hitcost = 2000 throw_hit_chance = 10 slot_flags = ITEM_SLOT_BACK + makeshift = TRUE var/obj/item/assembly/igniter/sparkler = 0 /obj/item/melee/baton/cattleprod/Initialize() @@ -352,7 +363,7 @@ return FALSE /obj/item/batonupgrade - name = "Baton power upgrade" - desc = "A new power management circuit which enables double the power drain to instant stun." + name = "baton power upgrade" + desc = "A new power management circuit which enables stun batons to instantly stun, at the cost of double power usage." icon = 'icons/obj/module.dmi' icon_state = "cyborg_upgrade3" diff --git a/code/modules/research/designs/weapon_designs.dm b/code/modules/research/designs/weapon_designs.dm index 90f35515dd1b..fd0ca11ddef8 100644 --- a/code/modules/research/designs/weapon_designs.dm +++ b/code/modules/research/designs/weapon_designs.dm @@ -106,7 +106,7 @@ /datum/design/batonupgrade name = "Baton Power Upgrade" - desc = "A new power management circuit which enables double the power drain to instant stun." + desc = "A new power management circuit which enables stun batons to instantly stun, at the cost of more power usage." id = "baton_upgrade" build_type = PROTOLATHE materials = list(/datum/material/gold = 600, /datum/material/silver = 600, /datum/material/diamond = 600, /datum/material/uranium = 600, /datum/material/plasma = 600) From 7f18f489bf1d584a2b3ca2dd854266431cdf9126 Mon Sep 17 00:00:00 2001 From: Jamie D <993128+JamieD1@users.noreply.github.com> Date: Tue, 7 Jun 2022 22:20:09 +0100 Subject: [PATCH 8/9] Fixes batons not hitting people with implant check --- code/game/objects/items/stunbaton.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index a631622c0aa2..0ebb491f23ce 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -201,8 +201,6 @@ add_fingerprint(user) /obj/item/melee/baton/attack(mob/M, mob/living/carbon/human/user) - if(!handle_pins(user)) - return FALSE if(status && HAS_TRAIT(user, TRAIT_CLUMSY) && prob(50)) user.visible_message(span_danger("[user] accidentally hits [user.p_them()]self with [src]!"), \ span_userdanger("You accidentally hit yourself with [src]!")) @@ -250,6 +248,8 @@ /obj/item/melee/baton/proc/baton_stun(mob/living/L, mob/user) + if(!handle_pins(user)) + return FALSE if(upgrade) stamina_damage = initial(stamina_damage)*2 hitcost = initial(hitcost)*1.5 From 5ee9a0acc4ced01c75d77b19f033883426676718 Mon Sep 17 00:00:00 2001 From: TheGamerdk <5618080+TheGamerdk@users.noreply.github.com> Date: Wed, 8 Jun 2022 20:30:43 +0200 Subject: [PATCH 9/9] Apply suggestions from code review --- code/game/objects/items/stunbaton.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 0ebb491f23ce..1b2052f6f1cc 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -130,7 +130,7 @@ to_chat(user, span_notice("You install a cell in [src].")) update_icon() else if(istype(W, /obj/item/firing_pin)) - if(makeshift == TRUE) + if(makeshift) return if(upgrade) if(W.type != /obj/item/firing_pin) @@ -142,7 +142,7 @@ W.forceMove(src) pin = W else if(istype(W, upgrade)) - if(makeshift == TRUE) + if(makeshift) return if(pin) if(pin.type != /obj/item/firing_pin) @@ -154,7 +154,7 @@ W.forceMove(src) upgrade = W else if(W.tool_behaviour == TOOL_CROWBAR) - if(makeshift == TRUE) + if(makeshift) return if(pin) pin.forceMove(get_turf(src))