Skip to content

Commit

Permalink
Merge pull request tgstation#6727 from HippieStation/upstream-merge-3…
Browse files Browse the repository at this point in the history
…5727

[MIRROR] Redeems my sins. Defib mount fixes.
  • Loading branch information
JohnGinnane committed Feb 19, 2018
2 parents 0508922 + f0db337 commit f7e3390
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
16 changes: 5 additions & 11 deletions code/game/machinery/defibrillator_mount.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use_power = IDLE_POWER_USE
idle_power_usage = 1
power_channel = EQUIP
speed_process = TRUE //GAS GAS GAS
req_one_access = list(ACCESS_MEDICAL, ACCESS_HEADS, ACCESS_SECURITY) //used to control clamps
var/obj/item/defibrillator/defib //this mount's defibrillator
var/clamps_locked = FALSE //if true, and a defib is loaded, it can't be removed without unlocking the clamps
Expand All @@ -35,16 +34,11 @@
to_chat(user, "<span class='notice'>Its locking clamps can be [clamps_locked ? "dis" : ""]engaged by swiping an ID with access.</span>")

/obj/machinery/defibrillator_mount/process()
if(defib && defib.cell && defib.cell.charge < defib.cell.maxcharge)
use_power(20)
defib.cell.give(18) //90% efficiency, slightly better than the cell charger's 87.5%
if(defib && defib.paddles && isliving(defib.paddles.loc))
var/mob/living/L = defib.paddles.loc
if(!L.Adjacent(src))
to_chat(L, "<span class='warning'>[defib]'s paddles overextend and come out of your hands!</span>")
L.dropItemToGround(defib.paddles)
update_icon()

if(defib && defib.cell && defib.cell.charge < defib.cell.maxcharge && is_operational())
use_power(200)
defib.cell.give(180) //90% efficiency, slightly better than the cell charger's 87.5%
update_icon()

/obj/machinery/defibrillator_mount/update_icon()
cut_overlays()
if(defib)
Expand Down
37 changes: 34 additions & 3 deletions code/game/objects/items/defib.dm
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,30 @@
var/grab_ghost = FALSE
var/tlimit = DEFIB_TIME_LIMIT * 10

var/datum/component/mobhook

/obj/item/twohanded/shockpaddles/equipped(mob/user, slot)
. = ..()
if(req_defib)
if (mobhook && mobhook.parent != user)
QDEL_NULL(mobhook)
if (!mobhook)
mobhook = user.AddComponent(/datum/component/redirect, list(COMSIG_MOVABLE_MOVED), CALLBACK(src, .proc/check_range))

/obj/item/twohanded/shockpaddles/Moved()
. = ..()
check_range()

/obj/item/twohanded/shockpaddles/proc/check_range()
if(!in_range(src,defib))
var/mob/living/L = loc
if(istype(L))
to_chat(L, "<span class='warning'>[defib]'s paddles overextend and come out of your hands!</span>")
L.temporarilyRemoveItemFromInventory(src,TRUE)
else
visible_message("<span class='notice'>[src] snap back into [defib].</span>")
snap_back()

/obj/item/twohanded/shockpaddles/proc/recharge(var/time)
if(req_defib || !time)
return
Expand Down Expand Up @@ -331,16 +355,23 @@
/obj/item/twohanded/shockpaddles/dropped(mob/user)
if(!req_defib)
return ..()
if (mobhook)
QDEL_NULL(mobhook)
if(user)
var/obj/item/twohanded/offhand/O = user.get_inactive_held_item()
if(istype(O))
O.unwield()
to_chat(user, "<span class='notice'>The paddles snap back into the main unit.</span>")
defib.on = 0
forceMove(defib)
defib.update_icon()
snap_back()
return unwield(user)

/obj/item/twohanded/shockpaddles/proc/snap_back()
if(!defib)
return
defib.on = FALSE
forceMove(defib)
defib.update_icon()

/obj/item/twohanded/shockpaddles/proc/check_defib_exists(mainunit, mob/living/carbon/M, obj/O)
if(!req_defib)
return TRUE //If it doesn't need a defib, just say it exists
Expand Down

0 comments on commit f7e3390

Please sign in to comment.