Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removes synth defib kits #6851

Merged
merged 3 commits into from
Nov 26, 2024
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
4 changes: 3 additions & 1 deletion citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
#include "code\__DEFINES\inventory\rendering.dm"
#include "code\__DEFINES\inventory\slots.dm"
#include "code\__DEFINES\inventory\storage.dm"
#include "code\__DEFINES\items\defib.dm"
#include "code\__DEFINES\items\hypospray.dm"
#include "code\__DEFINES\items\inducer.dm"
#include "code\__DEFINES\items\nifs.dm"
Expand Down Expand Up @@ -1642,14 +1643,15 @@
#include "code\game\objects\items\circuitboards\machinery\ships.dm"
#include "code\game\objects\items\circuitboards\machinery\telecomms.dm"
#include "code\game\objects\items\circuitboards\machinery\unary_atmos.dm"
#include "code\game\objects\items\defib\defib_kit.dm"
#include "code\game\objects\items\defib\shockpaddles.dm"
#include "code\game\objects\items\devices\advnifrepair.dm"
#include "code\game\objects\items\devices\ai_detector.dm"
#include "code\game\objects\items\devices\aicard.dm"
#include "code\game\objects\items\devices\binoculars.dm"
#include "code\game\objects\items\devices\body_snatcher_vr.dm"
#include "code\game\objects\items\devices\chameleonproj.dm"
#include "code\game\objects\items\devices\debugger.dm"
#include "code\game\objects\items\devices\defib.dm"
#include "code\game\objects\items\devices\flash.dm"
#include "code\game\objects\items\devices\flashlight.dm"
#include "code\game\objects\items\devices\floor_painter.dm"
Expand Down
5 changes: 5 additions & 0 deletions code/__DEFINES/items/defib.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

///past this many seconds, defib will cause maximum brain damage.
#define DEFIB_TIME_LIMIT (10 MINUTES)
///past this many seconds, brain damage occurs.
#define DEFIB_TIME_LOSS (2 MINUTES)
9 changes: 6 additions & 3 deletions code/__DEFINES/items/inducer.dm
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// /inducer_act returns
//* /atom/proc/inducer_act returns *//

/// continue without using charge
#define INDUCER_ACT_CONTINUE "continue"
/// immediately stop
#define INDUCER_ACT_STOP "stop"

// /inducer_scan returns
//* /inducer_scan returns *//

/// normal - use list
#define INDUCER_SCAN_NORMAL 0
/// ignore scan result, silent fail
Expand All @@ -14,6 +16,7 @@
/// say something is full
#define INDUCER_SCAN_FULL 3

// /inducer/var/inducer_flags
//* /obj/item/inducer/var/inducer_flags *//

/// no using on guns
#define INDUCER_NO_GUNS (1<<0)
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@
)
worth = 250 // literally only because of the flashes; nerf flashes when?

/datum/supply_pack/nanotrasen/robotics/jumper_cables
name = "Jumper kit crate"
contains = list(
/obj/item/defib_kit/jumper_kit = 2,
)
worth = 250

/datum/supply_pack/nanotrasen/robotics/restrainingbolt
name = "Restraining bolt crate"
contains = list(
Expand Down
179 changes: 179 additions & 0 deletions code/game/objects/items/defib/defib_kit.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
// todo: rework defibs
// todo: object cell system

//backpack item
/obj/item/defib_kit
name = "defibrillator"
desc = "A device that delivers powerful shocks to detachable paddles that resuscitate incapacitated patients."
icon = 'icons/obj/medical/defibrillator.dmi'
icon_state = "defibunit"
item_state = "defibunit"
slot_flags = SLOT_BACK
damage_force = 5
throw_force = 6
preserve_item = 1
w_class = WEIGHT_CLASS_BULKY
origin_tech = list(TECH_BIO = 4, TECH_POWER = 2)
item_action_name = "Remove/Replace Paddles"
worth_intrinsic = 300

var/obj/item/shockpaddles/linked/paddles
var/obj/item/cell/bcell = null

/obj/item/defib_kit/Initialize(mapload) //starts without a cell for rnd
. = ..()
if(ispath(paddles))
paddles = new paddles(src, src)
else
paddles = new(src, src)

if(ispath(bcell))
bcell = new bcell(src)
update_icon()

/obj/item/defib_kit/Destroy()
. = ..()
QDEL_NULL(paddles)
QDEL_NULL(bcell)

/obj/item/defib_kit/loaded //starts with a cell
bcell = /obj/item/cell/apc

/obj/item/defib_kit/update_icon()

cut_overlays()
var/list/new_overlays = list()

if(paddles && paddles.loc == src) //in case paddles got destroyed somehow.
new_overlays += "[initial(icon_state)]-paddles"
if(bcell && paddles)
if(bcell.check_charge(paddles.chargecost))
if(paddles.combat)
new_overlays += "[initial(icon_state)]-combat"
else if(!paddles.safety)
new_overlays += "[initial(icon_state)]-emagged"
else
new_overlays += "[initial(icon_state)]-powered"

var/ratio = CEILING(bcell.percent()/25, 1) * 25
new_overlays += "[initial(icon_state)]-charge[ratio]"
else
new_overlays += "[initial(icon_state)]-nocell"

add_overlay(new_overlays)

/obj/item/defib_kit/ui_action_click(datum/action/action, datum/event_args/actor/actor)
toggle_paddles()

/obj/item/defib_kit/attack_hand(mob/user, datum/event_args/actor/clickchain/e_args)
if(loc == user)
toggle_paddles()
else
..()

/obj/item/defib_kit/attackby(obj/item/W, mob/user, params)
if(W == paddles)
reattach_paddles(user)
return CLICKCHAIN_DO_NOT_PROPAGATE
else if(istype(W, /obj/item/cell))
if(bcell)
to_chat(user, "<span class='notice'>\the [src] already has a cell.</span>")
return CLICKCHAIN_DO_NOT_PROPAGATE
else
if(!user.attempt_insert_item_for_installation(W, src))
return CLICKCHAIN_DO_NOT_PROPAGATE
bcell = W
to_chat(user, "<span class='notice'>You install a cell in \the [src].</span>")
update_icon()
return CLICKCHAIN_DO_NOT_PROPAGATE

else if(W.is_screwdriver())
if(bcell)
bcell.update_icon()
bcell.forceMove(get_turf(src.loc))
bcell = null
to_chat(user, "<span class='notice'>You remove the cell from \the [src].</span>")
update_icon()
return CLICKCHAIN_DO_NOT_PROPAGATE
else
return ..()

/obj/item/defib_kit/emag_act(var/remaining_charges, var/mob/user)
if(paddles)
. = paddles.emag_act(user)
update_icon()
return

//Paddle stuff

/obj/item/defib_kit/verb/toggle_paddles()
set name = "Toggle Paddles"
set category = VERB_CATEGORY_OBJECT

var/mob/living/carbon/human/user = usr
if(!paddles)
to_chat(user, "<span class='warning'>The paddles are missing!</span>")
return

if(paddles.loc != src)
reattach_paddles(user) //Remove from their hands and back onto the defib unit
return

if(!slot_check())
to_chat(user, "<span class='warning'>You need to equip [src] before taking out [paddles].</span>")
else
if(!usr.put_in_hands(paddles)) //Detach the paddles into the user's hands
to_chat(user, "<span class='warning'>You need a free hand to hold the paddles!</span>")
update_icon() //success

//checks that the base unit is in the correct slot to be used
/obj/item/defib_kit/proc/slot_check()
var/mob/M = loc
if(!istype(M))
return 0 //not equipped

if((slot_flags & SLOT_BACK) && M.item_by_slot_id(SLOT_ID_BACK) == src)
return 1
if((slot_flags & SLOT_BELT) && M.item_by_slot_id(SLOT_ID_BELT) == src)
return 1

return 0

/obj/item/defib_kit/unequipped(mob/user, slot, flags)
. = ..()
reattach_paddles(user) //paddles attached to a base unit should never exist outside of their base unit or the mob equipping the base unit

/obj/item/defib_kit/proc/reattach_paddles(mob/user)
if(!paddles)
return

if(ismob(paddles.loc))
to_chat(paddles.loc, "<span class='notice'>\The [paddles] snap back into the main unit.</span>")
paddles.forceMove(src)
update_icon()

/*
Base Unit Subtypes
*/

/obj/item/defib_kit/compact
name = "compact defibrillator"
desc = "A belt-equipped defibrillator that can be rapidly deployed."
icon_state = "defibcompact"
item_state = "defibcompact"
w_class = WEIGHT_CLASS_NORMAL
slot_flags = SLOT_BELT
origin_tech = list(TECH_BIO = 5, TECH_POWER = 3)
worth_intrinsic = 500

/obj/item/defib_kit/compact/loaded
bcell = /obj/item/cell/high


/obj/item/defib_kit/compact/combat
name = "combat defibrillator"
desc = "A belt-equipped blood-red defibrillator that can be rapidly deployed. Does not have the restrictions or safeties of conventional defibrillators and can revive through space suits."
paddles = /obj/item/shockpaddles/linked/combat

/obj/item/defib_kit/compact/combat/loaded
bcell = /obj/item/cell/high
Loading
Loading