Skip to content

Commit

Permalink
[MIRROR] Refactors reviver code [MDB IGNORE] (#25691)
Browse files Browse the repository at this point in the history
* Refactors reviver code (#80386)

## About The Pull Request

Cleans up reviver code to overall make it simpler and properly implement
the cooldown that it said it had in the code but never really had.
Additionally, stops the reviver trying to revive someone that isn't in a
revivable state, which fixes
tgstation/tgstation#80371. Wasn't sure how
long to make the delay but I figured just a 5 second delay after the
first heal proc should be fine. About the same as what the original
cooldown was from being paired to the heal proc's second iteration.
## Why It's Good For The Game

Changes variables and checks used by the reviver to make sure it
functions properly with the cooldown that seemed to be intended in the
code. Additionally, prevents the reviver from infinitely defibbing a
non-revivable corpse.
## Changelog
:cl:
fix: Reviver no longer attempts to revive impossible to defib mobs.
refactor: Cleaned up unnecessary variables and re-arraigned code to have
it perform altogether in one tick. Additionally added a proper cooldown
to revivers.
/:cl:

* Refactors reviver code

---------

Co-authored-by: Diamond_ <[email protected]>
  • Loading branch information
2 people authored and FFMirrorBot committed Dec 17, 2023
1 parent fd68ecc commit f55a454
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions code/modules/surgery/organs/internal/cyberimp/augments_chest.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@
slot = ORGAN_SLOT_HEART_AID
var/revive_cost = 0
var/reviving = FALSE
/// revival/defibrillation possibility flag that gathered from owner's .can_defib() proc
var/can_defib_owner
COOLDOWN_DECLARE(reviver_cooldown)
COOLDOWN_DECLARE(defib_cooldown)

/obj/item/organ/internal/cyberimp/chest/reviver/on_death(seconds_per_tick, times_fired)
if(isnull(owner)) // owner can be null, on_death() gets called by /obj/item/organ/internal/process() for decay
Expand All @@ -81,19 +80,13 @@
revive_cost = 0
reviving = TRUE
to_chat(owner, span_notice("You feel a faint buzzing as your reviver implant starts patching your wounds..."))
COOLDOWN_START(src, defib_cooldown, 8 SECONDS) // 5 seconds after heal proc delay


/obj/item/organ/internal/cyberimp/chest/reviver/proc/heal()
if(can_defib_owner == DEFIB_POSSIBLE)
if(COOLDOWN_FINISHED(src, defib_cooldown))
revive_dead()
can_defib_owner = null
revive_cost += 10 MINUTES // Additional 10 minutes cooldown after revival.
// this check goes after revive_dead() to delay revival a bit
if(owner.stat == DEAD)
can_defib_owner = owner.can_defib()
if(can_defib_owner == DEFIB_POSSIBLE)
owner.notify_revival("You are being revived by [src]!")
owner.grab_ghost()

/// boolean that stands for if PHYSICAL damage being patched
var/body_damage_patched = FALSE
var/need_mob_update = FALSE
Expand All @@ -119,8 +112,14 @@


/obj/item/organ/internal/cyberimp/chest/reviver/proc/revive_dead()
if(!COOLDOWN_FINISHED(src, defib_cooldown) || owner.stat != DEAD || owner.can_defib() != DEFIB_POSSIBLE)
return
owner.notify_revival("You are being revived by [src]!")
revive_cost += 10 MINUTES // Additional 10 minutes cooldown after revival.
owner.grab_ghost()

defib_cooldown += 16 SECONDS // delay so it doesn't spam

owner.visible_message(span_warning("[owner]'s body convulses a bit."))
playsound(owner, SFX_BODYFALL, 50, TRUE)
playsound(owner, 'sound/machines/defib_zap.ogg', 75, TRUE, -1)
Expand Down

0 comments on commit f55a454

Please sign in to comment.