diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 824596960c55..2478ce7851bb 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -24,7 +24,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 @@ -35,6 +35,9 @@ 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 var/thrown = FALSE /obj/item/melee/baton/get_cell() @@ -52,9 +55,25 @@ 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) RegisterSignal(src, COMSIG_MOVABLE_PRE_DROPTHROW, .proc/throwbaton) update_icon() +/obj/item/melee/baton/Destroy() + . = ..() + 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(..()) return @@ -130,7 +149,44 @@ cell = W to_chat(user, span_notice("You install a cell in [src].")) update_icon() - + else if(istype(W, /obj/item/firing_pin)) + if(makeshift) + return + if(upgrade) + if(W.type != /obj/item/firing_pin) + 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.")) + else + W.forceMove(src) + pin = W + else if(istype(W, upgrade)) + if(makeshift) + 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 firing pin.") + return + 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(makeshift) + return + 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].")) + update_icon() else if(W.tool_behaviour == TOOL_SCREWDRIVER) if(cell) cell.update_icon() @@ -138,12 +194,14 @@ 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 ..() /obj/item/melee/baton/attack_self(mob/user) + if(!handle_pins(user)) + return FALSE if(dropcheck) to_chat(user, "[src]'s emergency shutoff is still active!") return @@ -187,7 +245,6 @@ ..() return - if(ishuman(M)) var/mob/living/carbon/human/L = M var/datum/martial_art/A = L.check_block() @@ -214,6 +271,13 @@ /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 + 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 @@ -232,6 +296,8 @@ var/obj/item/bodypart/affecting = L.get_bodypart(user? user.zone_selected : BODY_ZONE_CHEST) 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() @@ -299,6 +365,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() @@ -314,3 +381,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 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 567ba415525f..dcea347fd5fd 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 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) + 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 00887016893e..b3a10a569a3b 100644 --- a/code/modules/research/techweb/all_nodes.dm +++ b/code/modules/research/techweb/all_nodes.dm @@ -697,7 +697,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