Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 88 additions & 4 deletions code/game/objects/items/stunbaton.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -130,20 +149,59 @@
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()
cell.forceMove(get_turf(src))
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
Expand Down Expand Up @@ -187,7 +245,6 @@
..()
return


if(ishuman(M))
var/mob/living/carbon/human/L = M
var/datum/martial_art/A = L.check_block()
Expand All @@ -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
Expand All @@ -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()

Expand Down Expand Up @@ -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()
Expand All @@ -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"
10 changes: 10 additions & 0 deletions code/modules/research/designs/weapon_designs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion code/modules/research/techweb/all_nodes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down