Skip to content

Commit

Permalink
Smelling Salts Port (#74)
Browse files Browse the repository at this point in the history
* ports smelling salts

* adds smelling salts to map
  • Loading branch information
MarinaGryphon authored Mar 3, 2021
1 parent 163c0b6 commit b88903f
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 1 deletion.
8 changes: 7 additions & 1 deletion _maps/map_files/Pahrump/Pahrump-Surface-2.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,7 @@
/obj/structure/table/wood/settler,
/obj/item/reagent_containers/pill/patch/healingpowder,
/obj/item/reagent_containers/pill/patch/healingpowder,
/obj/item/smelling_salts/wayfarer,
/turf/open/indestructible/ground/inside/mountain,
/area/f13/village)
"aOE" = (
Expand Down Expand Up @@ -1393,6 +1394,11 @@
/obj/structure/bed/dogbed,
/turf/open/floor/f13/wood,
/area/f13/building)
"aXV" = (
/obj/structure/table/wood,
/obj/item/smelling_salts,
/turf/open/floor/f13/wood,
/area/f13/legion)
"aYk" = (
/obj/structure/sink{
pixel_y = 15
Expand Down Expand Up @@ -93887,7 +93893,7 @@ gcK
gcK
hom
gsV
tHw
aXV
xNm
hom
gcK
Expand Down
110 changes: 110 additions & 0 deletions code/modules/fallout/obj/smelling_salts.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
//smelling salts
/obj/item/smelling_salts
name = "large phial of smelling salts"
desc = "A large glass phial of pungent smelling salts, used to revive those who have fainted."
w_class = WEIGHT_CLASS_NORMAL
icon = 'icons/obj/fallout/smelling_salts.dmi'
icon_state = "smelling_salts_legion"
var/time_limit = DEFIB_TIME_LIMIT * 5 // half compared to an actual defib
var/charges = 8 // a bit lower than a normal defib's 10
var/in_use = FALSE
var/time_to_use = 10 SECONDS // a defib is 5 seconds

/obj/item/smelling_salts/wayfarer
icon_state = "smelling_salts_wayfarer"

/obj/item/smelling_salts/crafted
name = "small phial of smelling salts"
w_class = WEIGHT_CLASS_SMALL // unsure about this balance-wise, given that defibs are bulky
desc = "A stoppered glass phial of pungent smelling salts, used to revive those who have fainted."
icon_state = "smelling_salts_crafted"
charges = 4 // half of the premade smelling salts

/obj/item/smelling_salts/attack(mob/target, mob/user)
if(in_use)
return
if(!user.IsAdvancedToolUser())
to_chat(user, SPAN_WARNING("You don't know how to use [src]!"))
return
if(!iscarbon(target))
to_chat(user, SPAN_WARNING("Do smelling salts even work on that?"))
return
var/mob/living/carbon/target_carbon = target

if(user.zone_selected != BODY_ZONE_PRECISE_MOUTH && user.zone_selected != BODY_ZONE_HEAD)
to_chat(user, SPAN_WARNING("[target_carbon] has to smell [src] to be revived, hold it up to their face!"))

if((target_carbon.head?.flags_cover & HEADCOVERSMOUTH) || (target_carbon.wear_mask?.flags_cover & MASKCOVERSMOUTH))
to_chat(user, SPAN_NOTICE("You're going to need to remove that [(target_carbon.head?.flags_cover & HEADCOVERSMOUTH) ? "helmet" : "mask"] first."))
return

else if(target_carbon.can_revive_smellingsalts())
target_carbon.notify_ghost_cloning("You're being revived with smelling salts. Re-enter your corpse if you want to be revived!", source = src)

do_revive(target_carbon, user)
if(--charges <= 0)
qdel(src)

/obj/item/smelling_salts/proc/do_revive(mob/living/carbon/revived_mob, mob/living/user)
in_use = TRUE
if(!do_after(user, time_to_use, target = revived_mob))
return
user.visible_message(SPAN_NOTICE("[user] starts waving [src] under [revived_mob]'s nose."), SPAN_WARNING("You wave [src] under [revived_mob]'s nose."))
var/time_since_death = world.time - revived_mob.timeofdeath
// past this much time the patient is unrecoverable
// (in deciseconds)
// brain damage starts setting in on the patient after
// some time left rotting
var/total_burn = 0
var/total_brute = 0
if(!do_after(user, 20, target = revived_mob)) //placed on chest and short delay to shock for dramatic effect, revive time is 5sec total
in_use = FALSE
return
if((revived_mob.head?.flags_cover & HEADCOVERSMOUTH) || (revived_mob.wear_mask?.flags_cover & MASKCOVERSMOUTH)) // should've been checked prior, so it must've been put on during the pause
to_chat(user, SPAN_NOTICE("You're going to need to remove that [(revived_mob.head?.flags_cover & HEADCOVERSMOUTH) ? "helmet" : "mask"] again."))
in_use = FALSE
return
if(revived_mob.stat != DEAD)
in_use = FALSE
revived_mob.emote("cough")
return
total_brute = revived_mob.getBruteLoss()
total_burn = revived_mob.getFireLoss()

if (!revived_mob.can_revive_smellingsalts())
revived_mob.visible_message(SPAN_WARNING("[revived_mob] doesn't respond..."))
in_use = FALSE
return
else if(revived_mob.get_ghost())
revived_mob.visible_message(SPAN_WARNING("[revived_mob] gasps, but doesn't stir yet."))
to_chat(user, SPAN_NOTICE("Perhaps they need another dose?"))
in_use = FALSE
return
//If the body has been fixed so that they would not be in crit when revived, give them oxyloss to put them back into crit
var/const/threshold = ((HEALTH_THRESHOLD_CRIT + HEALTH_THRESHOLD_DEAD) * 0.5)
if (revived_mob.health > threshold)
revived_mob.adjustOxyLoss(revived_mob.health - threshold, 0)
else
var/overall_damage = total_brute + total_burn + revived_mob.getToxLoss() + revived_mob.getOxyLoss()
var/mobhealth = revived_mob.health
revived_mob.adjustOxyLoss((mobhealth - threshold) * (revived_mob.getOxyLoss() / overall_damage), 0)
revived_mob.adjustToxLoss((mobhealth - threshold) * (revived_mob.getToxLoss() / overall_damage), 0)
revived_mob.adjustFireLoss((mobhealth - threshold) * (total_burn / overall_damage), 0)
revived_mob.adjustBruteLoss((mobhealth - threshold) * (total_brute / overall_damage), 0)
revived_mob.updatehealth() // Previous "adjust" procs don't update health, so we do it manually.
revived_mob.visible_message(SPAN_NOTICE("[revived_mob] gasps and stirs!"))
revived_mob.set_heartattack(FALSE) // if you can safely be revived without this, then this should be removed; smelling salts aren't a defib
revived_mob.revive()
revived_mob.emote("gasp")
revived_mob.Jitter(20)
if(time_since_death > time_limit)
revived_mob.adjustOrganLoss(ORGAN_SLOT_BRAIN, max(0, min(99, ((time_limit - time_since_death) / time_limit * 100))), 150)
log_combat(revived_mob, revived_mob, "revived", src)
var/list/policies = CONFIG_GET(keyed_list/policyconfig)
var/memory_limit = CONFIG_GET(number/defib_cmd_time_limit)
var/late = memory_limit && (time_since_death > memory_limit)
var/policy = late? policies[POLICYCONFIG_ON_DEFIB_LATE] : policies[POLICYCONFIG_ON_DEFIB_INTACT]
if(policy)
to_chat(revived_mob, policy)
revived_mob.log_message("revived using strange reagent, [time_since_death / 10] seconds from time of death, considered [late? "late" : "memory-intact"] revival under configured policy limits.", LOG_GAME)
in_use = FALSE
16 changes: 16 additions & 0 deletions code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,22 @@
return
return TRUE

/mob/living/carbon/proc/can_revive_smellingsalts()
var/tlimit = DEFIB_TIME_LIMIT * 5
var/obj/item/organ/heart = getorgan(/obj/item/organ/heart)
if(suiciding || hellbound || HAS_TRAIT(src, TRAIT_HUSK) || AmBloodsucker(src))
return
if((world.time - timeofdeath) > tlimit)
return
if((getBruteLoss() >= 160) || (getFireLoss() >= 160))
return
if(!heart || (heart.organ_flags & ORGAN_FAILING))
return
var/obj/item/organ/brain/BR = getorgan(/obj/item/organ/brain)
if(QDELETED(BR) || BR.brain_death || (BR.organ_flags & ORGAN_FAILING) || suiciding)
return
return TRUE

/mob/living/carbon/fully_heal(admin_revive = FALSE)
if(reagents)
reagents.clear_reagents()
Expand Down
3 changes: 3 additions & 0 deletions config/policy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
## EXAMPLE:
## POLICYCONFIG ON_CLONE insert text here <span class='notice'>span classes are fully supported</span>

POLICYCONFIG ON_DEFIB_INTACT <span class='notice'>You have been revived, with your memory fully intact.</span>
POLICYCONFIG ON_DEFIB_LATE <span class='warning'>You have been revived, but after enough time to suffer substantial memory loss. You cannot recall the events that led to your temporary demise.</span>

## Misc entries for above

## Defib time limit for "cloning memory disorder" memory loss in seconds
Expand Down
Binary file added icons/obj/fallout/smelling_salts.dmi
Binary file not shown.
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -2102,6 +2102,7 @@
#include "code\modules\fallout\obj\explosives.dm"
#include "code\modules\fallout\obj\holodisks.dm"
#include "code\modules\fallout\obj\items.dm"
#include "code\modules\fallout\obj\smelling_salts.dm"
#include "code\modules\fallout\obj\snacks.dm"
#include "code\modules\fallout\obj\trash.dm"
#include "code\modules\fallout\obj\trash_stack.dm"
Expand Down

0 comments on commit b88903f

Please sign in to comment.