Skip to content

Commit

Permalink
[PORT] Mobile defib mounts from TG (PR#83000) (#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
TyrantCerberus authored May 28, 2024
1 parent 6612002 commit a12e895
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 11 deletions.
12 changes: 12 additions & 0 deletions code/datums/components/crafting/recipes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1801,5 +1801,17 @@
category = CAT_ENTERTAINMENT
time = 10 SECONDS

/datum/crafting_recipe/defib_mobile
name = "Mobile Defibrillator Mount"
reqs = list(
/obj/item/stack/sheet/mineral/silver = 1,
/obj/item/stack/sheet/iron = 5,
/obj/item/stack/cable_coil = 15,
)
result = /obj/machinery/defibrillator_mount/mobile
tool_behaviors = list(TOOL_SCREWDRIVER)
category = CAT_FURNITURE
time = 7 SECONDS

#undef CRAFTING_MACHINERY_CONSUME
#undef CRAFTING_MACHINERY_USE
56 changes: 45 additions & 11 deletions code/game/machinery/defibrillator_mount.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,23 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/defibrillator_mount, 28)
/obj/machinery/defibrillator_mount/update_overlays()
. = ..()

if(!defib)
if(isnull(defib))
return

. += "defib"
var/mutable_appearance/defib_overlay = mutable_appearance(icon, "defib", layer = layer+0.01)

if(defib.powered)
var/obj/item/stock_parts/cell/C = get_cell()
. += (defib.safety ? "online" : "emagged")
var/ratio = C.charge / C.maxcharge
ratio = CEILING(ratio * 4, 1) * 25
. += "charge[ratio]"
var/obj/item/stock_parts/cell/cell = defib.cell
var/mutable_appearance/safety = mutable_appearance(icon, defib.safety ? "online" : "emagged")
var/mutable_appearance/charge_overlay = mutable_appearance(icon, "charge[CEILING((cell.charge / cell.maxcharge) * 4, 1) * 25]")

defib_overlay.overlays += list(safety, charge_overlay)

if(clamps_locked)
. += "clamps"
var/mutable_appearance/clamps = mutable_appearance(icon, "clamps")
defib_overlay.overlays += clamps

/obj/machinery/defibrillator_mount/get_cell()
if(defib)
return defib.get_cell()
. += defib_overlay

//defib interaction
/obj/machinery/defibrillator_mount/attack_hand(mob/living/user, list/modifiers)
Expand Down Expand Up @@ -223,3 +222,38 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/defibrillator_mount, 28)
icon_state = "penlite_mount"
custom_materials = list(/datum/material/iron = 300, /datum/material/glass = 100, /datum/material/silver = 50)
result_path = /obj/machinery/defibrillator_mount/charging

//mobile defib

/obj/machinery/defibrillator_mount/mobile
name = "mobile defibrillator mount"
icon_state = "mobile"
anchored = FALSE
density = TRUE

/obj/machinery/defibrillator_mount/mobile/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE)
. = ..()
if(has_gravity())
playsound(src, 'sound/effects/roll.ogg', 100, TRUE)

/obj/machinery/defibrillator_mount/mobile/wrench_act_secondary(mob/living/user, obj/item/tool)
if(user.combat_mode)
return ..()
if(defib)
to_chat(user, span_warning("The mount can't be deconstructed while a defibrillator unit is loaded!"))
..()
return TRUE
balloon_alert(user, "deconstructing...")
tool.play_tool_sound(src)
if(tool.use_tool(src, user, 5 SECONDS))
playsound(loc, 'sound/items/deconstruct.ogg', 50, vary = TRUE)
deconstruct()
return TRUE

/obj/machinery/defibrillator_mount/mobile/on_deconstruction(disassembled)
if(disassembled)
new /obj/item/stack/sheet/iron(drop_location(), 5)
new /obj/item/stack/sheet/mineral/silver(drop_location(), 1)
new /obj/item/stack/cable_coil(drop_location(), 15)
else
new /obj/item/stack/sheet/iron(drop_location(), 5)
2 changes: 2 additions & 0 deletions code/game/objects/items/defib.dm
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
if(!req_defib)
return
RegisterSignal(user, COMSIG_MOVABLE_MOVED, PROC_REF(check_range))
RegisterSignal(defib.loc, COMSIG_MOVABLE_MOVED, PROC_REF(check_range))

/obj/item/shockpaddles/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE)
. = ..()
Expand Down Expand Up @@ -425,6 +426,7 @@
. = ..()
if(user)
UnregisterSignal(user, COMSIG_MOVABLE_MOVED)
UnregisterSignal(defib.loc, COMSIG_MOVABLE_MOVED)
if(req_defib)
if(user)
to_chat(user, span_notice("The paddles snap back into the main unit."))
Expand Down
Binary file modified icons/obj/machines/defib_mount.dmi
Binary file not shown.

0 comments on commit a12e895

Please sign in to comment.