Refactors lava into being a component with different types for toxic water and plasma rivers (#22017)

* modified

* refactor lava into component

* Update lava.dm

* Update lava.dm
This commit is contained in:
Molti
2024-05-27 21:22:44 -05:00
committed by GitHub
parent 7c9246ca90
commit 5fe1430b18
9 changed files with 285 additions and 228 deletions

View File

@@ -173,9 +173,8 @@
continue
if(extended_safety_checks)
if(islava(F)) //chasms aren't /floor, and so are pre-filtered
var/turf/open/lava/L = F
if(!L.is_safe())
var/datum/component/lava/safety_check = F.GetComponent(/datum/component/lava)
if(safety_check && !safety_check.is_safe()) //chasms aren't /floor, and so are pre-filtered
continue
// Check that we're not warping onto a table or window

View File

@@ -34,6 +34,7 @@
if(!smoothing_flags)
update_appearance()
AddComponent(/datum/component/fishable/lava)
AddComponent(/datum/component/lava)
/turf/open/lava/update_overlays()
. = ..()
@@ -112,25 +113,6 @@
/turf/open/lava/airless
initial_gas_mix = AIRLESS_ATMOS
/turf/open/lava/Entered(atom/movable/AM)
if(burn_stuff(AM))
START_PROCESSING(SSobj, src)
/turf/open/lava/Exited(atom/movable/Obj, atom/newloc)
. = ..()
if(isliving(Obj))
var/mob/living/L = Obj
if(!islava(newloc) && !L.on_fire)
L.update_fire()
/turf/open/lava/hitby(atom/movable/AM, skipcatch, hitpush, blocked, datum/thrownthing/throwingdatum)
if(burn_stuff(AM))
START_PROCESSING(SSobj, src)
/turf/open/lava/process(delta_time)
if(!burn_stuff(null, delta_time))
STOP_PROCESSING(SSobj, src)
/turf/open/lava/rcd_vals(mob/user, obj/item/construction/rcd/the_rcd)
switch(the_rcd.construction_mode)
if(RCD_FLOORWALL)
@@ -168,77 +150,6 @@
/turf/open/lava/TakeTemperature(temp)
/turf/open/lava/proc/is_safe()
//if anything matching this typecache is found in the lava, we don't burn things
var/static/list/lava_safeties_typecache = typecacheof(list(/obj/structure/lattice/catwalk, /obj/structure/stone_tile))
var/list/found_safeties = typecache_filter_list(contents, lava_safeties_typecache)
for(var/obj/structure/stone_tile/S in found_safeties)
if(S.fallen)
LAZYREMOVE(found_safeties, S)
return LAZYLEN(found_safeties)
/turf/open/lava/proc/burn_stuff(AM, delta_time = 1)
. = 0
if(is_safe())
return FALSE
var/thing_to_check = src
if (AM)
thing_to_check = list(AM)
for(var/thing in thing_to_check)
if(isobj(thing))
var/obj/O = thing
if((O.resistance_flags & (LAVA_PROOF|INDESTRUCTIBLE)) || O.throwing)
continue
. = 1
if((O.resistance_flags & (ON_FIRE)))
continue
if(!(O.resistance_flags & FLAMMABLE))
O.resistance_flags |= FLAMMABLE //Even fireproof things burn up in lava
if(O.resistance_flags & FIRE_PROOF)
O.resistance_flags &= ~FIRE_PROOF
if(O.armor.fire > 50) //obj with 100% fire armor still get slowly burned away.
O.armor = O.armor.setRating(fire = 50)
O.fire_act(10000, 1000 * delta_time)
else if (isliving(thing))
. = 1
var/mob/living/L = thing
if(L.movement_type & FLYING)
continue //YOU'RE FLYING OVER IT
var/buckle_check = L.buckling
if(!buckle_check)
buckle_check = L.buckled
if(isobj(buckle_check))
var/obj/O = buckle_check
if(O.resistance_flags & LAVA_PROOF)
continue
else if(isliving(buckle_check))
var/mob/living/live = buckle_check
if("lava" in live.weather_immunities)
continue
if(!L.on_fire)
L.update_fire()
if(iscarbon(L))
var/mob/living/carbon/C = L
var/obj/item/clothing/S = C.get_item_by_slot(ITEM_SLOT_OCLOTHING)
var/obj/item/clothing/H = C.get_item_by_slot(ITEM_SLOT_HEAD)
if(S && H && S.clothing_flags & LAVAPROTECT && H.clothing_flags & LAVAPROTECT)
return
if("lava" in L.weather_immunities)
continue
L.adjustFireLoss(20 * delta_time)
if(L) //mobs turning into object corpses could get deleted here.
L.adjust_fire_stacks(20 * delta_time)
L.ignite_mob()
/turf/open/lava/smooth
name = "lava"
baseturfs = /turf/open/lava/smooth

View File

@@ -174,6 +174,10 @@
light_color = LIGHT_COLOR_PURPLE
lava_temperature = 73 // cold, not hot
/turf/open/lava/plasma/Initialize(mapload)
. = ..()
AddComponent(/datum/component/lava/plasma) //overwrites the regular lava component
/turf/open/lava/plasma/attackby(obj/item/I, mob/user, params)
var/obj/item/reagent_containers/glass/C = I
if(C.reagents.total_volume >= C.volume)
@@ -182,88 +186,6 @@
C.reagents.add_reagent(/datum/reagent/toxin/plasma, rand(5, 10))
user.visible_message("[user] scoops some plasma from the [src] with \the [C].", span_notice("You scoop out some plasma from the [src] using \the [C]."))
/turf/open/lava/plasma/burn_stuff(AM)
. = 0
if(is_safe())
return FALSE
var/thing_to_check = src
if (AM)
thing_to_check = list(AM)
for(var/thing in thing_to_check)
if(isobj(thing))
var/obj/O = thing
if((O.resistance_flags & (FREEZE_PROOF)) || O.throwing)
continue
else if (isliving(thing))
. = 1
var/mob/living/L = thing
if(L.movement_type & FLYING)
continue //YOU'RE FLYING OVER IT
if(WEATHER_SNOW in L.weather_immunities)
continue
var/buckle_check = L.buckling
if(!buckle_check)
buckle_check = L.buckled
if(isobj(buckle_check))
var/obj/O = buckle_check
if(O.resistance_flags & FREEZE_PROOF)
continue
else if(isliving(buckle_check))
var/mob/living/live = buckle_check
if(WEATHER_SNOW in live.weather_immunities)
continue
L.adjustFireLoss(2)
if(L)
L.adjust_fire_stacks(20) //dipping into a stream of plasma would probably make you more flammable than usual
L.adjust_bodytemperature(-rand(50,65)) //its cold, man
if(ishuman(L))//are they a carbon?
var/list/plasma_parts = list()//a list of the organic parts to be turned into plasma limbs
var/list/robo_parts = list()//keep a reference of robotic parts so we know if we can turn them into a plasmaman
var/mob/living/carbon/human/PP = L
var/datum/species/S = PP.dna.species
if(istype(S, /datum/species/plasmaman) || (S.inherent_biotypes & MOB_ROBOTIC)) //ignore plasmamen/robotic species
continue
for(var/BP in PP.bodyparts)
var/obj/item/bodypart/NN = BP
if(NN.status == BODYPART_ROBOTIC)
robo_parts += NN
if(NN.body_zone == BODY_ZONE_HEAD) //don't add the head to the list, just transform them into an plasmaman when it's the only thing left
continue
if(NN.status == BODYPART_ORGANIC && !(NN.species_id == "plasmaman" || NN.species_id == "husk")) //getting every organic, non-plasmaman limb (augments/androids are immune to this)
plasma_parts += NN
if(prob(35)) //checking if the delay is over & if the victim actually has any parts to nom
PP.adjustToxLoss(15)
PP.adjustFireLoss(25)
if(length(plasma_parts))
var/obj/item/bodypart/NB = pick(plasma_parts) //using the above-mentioned list to get a choice of limbs to replace
playsound(PP, 'sound/effects/wounds/sizzle2.ogg', 80, TRUE)
if(PP.stat != DEAD)
PP.emote("scream")
PP.visible_message(span_warning("[L] screams in pain as [L.p_their()] [NB] melts down to the bone!"), span_userdanger("You scream out in pain as your [NB] melts down to the bone, leaving an eerie plasma-like glow where flesh used to be!"))
else
PP.visible_message(span_warning("[L]'s [NB] melts down to the bone!"))
var/obj/item/bodypart/replacement_part = new NB.type
replacement_part.species_id = "plasmaman"
replacement_part.original_owner = "plasma river"
replacement_part.replace_limb(PP)
qdel(NB)
else if(!length(robo_parts)) //a person with no potential organic limbs left AND no robotic limbs, time to turn them into a plasmaman
PP.ignite_mob()
PP.cure_husk(BURN) //cure the probable husk first
PP.set_species(/datum/species/plasmaman)
PP.regenerate_icons()
PP.visible_message(span_warning("[L] bursts into a brilliant purple flame as [L.p_their()] entire body is that of a skeleton!"), \
span_userdanger("Your senses numb as all of your remaining flesh is turned into a purple slurry, sloshing off your body and leaving only your bones to show in a vibrant purple!"))
/obj/vehicle/ridden/lavaboat/plasma
name = "plasma boat"
desc = "A boat used for traversing the streams of plasma without turning into an icecube."

View File

@@ -141,9 +141,8 @@ GLOBAL_LIST_INIT(AISwarmerCapsByType, list(/mob/living/simple_animal/hostile/swa
/mob/living/simple_animal/hostile/swarmer/ai/Move(atom/newloc)
if(newloc)
if(newloc.z == z) //so these actions are Z-specific
if(islava(newloc))
var/turf/open/lava/L = newloc
if(!L.is_safe())
var/datum/component/lava/safety_check = newloc.GetComponent(/datum/component/lava)
if(safety_check && !safety_check.is_safe())
StartAction(20)
new /obj/structure/lattice/catwalk/swarmer_catwalk(newloc)
return FALSE

View File

@@ -64,7 +64,8 @@
return FALSE
/turf/open/lava/swarmer_act()
if(!is_safe())
var/datum/component/lava/safety_check = src.GetComponent(/datum/component/lava)
if(safety_check && !safety_check.is_safe()) //chasms aren't /floor, and so are pre-filtered
new /obj/structure/lattice/catwalk/swarmer_catwalk(src)
return FALSE

View File

@@ -6,7 +6,7 @@
desc = "A boat used for traversing lava."
icon_state = "goliath_boat"
icon = 'icons/obj/lavaland/dragonboat.dmi'
resistance_flags = LAVA_PROOF | FIRE_PROOF
resistance_flags = LAVA_PROOF | FIRE_PROOF | ACID_PROOF
can_buckle = TRUE
legs_required = 0
arms_required = 0
@@ -29,7 +29,7 @@
desc = "Not to be confused with the kind Research hassles you for."
force = 12
w_class = WEIGHT_CLASS_NORMAL
resistance_flags = LAVA_PROOF | FIRE_PROOF
resistance_flags = LAVA_PROOF | FIRE_PROOF | ACID_PROOF
/datum/crafting_recipe/oar
name = "Goliath Bone Oar"

View File

@@ -4029,6 +4029,7 @@
#include "yogstation\code\datums\components\crawl.dm"
#include "yogstation\code\datums\components\fishable.dm"
#include "yogstation\code\datums\components\fishingbonus.dm"
#include "yogstation\code\datums\components\lava.dm"
#include "yogstation\code\datums\components\pinnable_accessory.dm"
#include "yogstation\code\datums\components\radioactive.dm"
#include "yogstation\code\datums\components\randomcrits.dm"

View File

@@ -0,0 +1,253 @@
/datum/component/lava
var/turf/open/tile
dupe_type = /datum/component/lava //overwrite other types of lava
/datum/component/lava/Initialize()
if(!istype(parent, /turf))
return COMPONENT_INCOMPATIBLE
tile = parent
/datum/component/lava/RegisterWithParent()
. = ..()
RegisterSignal(parent, COMSIG_ATOM_HITBY, PROC_REF(hitby))
RegisterSignal(parent, COMSIG_ATOM_ENTERED, PROC_REF(Entered))
RegisterSignal(parent, COMSIG_ATOM_EXITED, PROC_REF(Exited))
tile = parent
/datum/component/lava/UnregisterFromParent()
. = ..()
UnregisterSignal(parent, COMSIG_ATOM_HITBY, PROC_REF(hitby))
UnregisterSignal(parent, COMSIG_ATOM_ENTERED, PROC_REF(Entered))
UnregisterSignal(parent, COMSIG_ATOM_EXITED, PROC_REF(Exited))
STOP_PROCESSING(SSobj, src)
////////////////////////////////////////////////////////////////////////////////////
//---------------------------------Triggers---------------------------------------//
////////////////////////////////////////////////////////////////////////////////////
/datum/component/lava/proc/hitby(datum/source, atom/movable/AM, skipcatch, hitpush, blocked, datum/thrownthing/throwingdatum)
if(damage_stuff(AM))
START_PROCESSING(SSobj, src)
/datum/component/lava/proc/Entered(datum/source, atom/movable/AM)
if(damage_stuff(AM))
START_PROCESSING(SSobj, src)
/datum/component/lava/proc/Exited(datum/source, atom/movable/Obj, atom/newloc)
if(isliving(Obj))
var/mob/living/L = Obj
if(!islava(newloc) && !L.on_fire)
L.update_fire()
/datum/component/lava/process(delta_time)
if(!damage_stuff(null, delta_time))
STOP_PROCESSING(SSobj, src)
////////////////////////////////////////////////////////////////////////////////////
//---------------------------------safety check-----------------------------------//
////////////////////////////////////////////////////////////////////////////////////
/datum/component/lava/proc/is_safe()
//if anything matching this typecache is found in the lava, we don't burn things
var/static/list/lava_safeties_typecache = typecacheof(list(/obj/structure/lattice/catwalk, /obj/structure/stone_tile))
var/list/found_safeties = typecache_filter_list(tile.contents, lava_safeties_typecache)
for(var/obj/structure/stone_tile/S in found_safeties)
if(S.fallen)
LAZYREMOVE(found_safeties, S)
return LAZYLEN(found_safeties)
/datum/component/lava/proc/damage_stuff(AM, delta_time = 1)
. = 0
if(is_safe())
return FALSE
var/thing_to_check = tile
if(!istype(thing_to_check, /turf))
return
if (AM)
thing_to_check = list(AM)
for(var/thing in thing_to_check)
if(apply_damage(thing, delta_time))
. = 1
////////////////////////////////////////////////////////////////////////////////////
//--------------------------------Do the effect-----------------------------------//
////////////////////////////////////////////////////////////////////////////////////
/datum/component/lava/proc/apply_damage(thing, delta_time) //override this for subtypes
. = 0
if(isobj(thing))
var/obj/O = thing
if((O.resistance_flags & (LAVA_PROOF|INDESTRUCTIBLE)) || O.throwing)
return
. = 1
if((O.resistance_flags & (ON_FIRE)))
return
if(!(O.resistance_flags & FLAMMABLE))
O.resistance_flags |= FLAMMABLE //Even fireproof things burn up in lava
if(O.resistance_flags & FIRE_PROOF)
O.resistance_flags &= ~FIRE_PROOF
if(O.armor.fire > 50) //obj with 100% fire armor still get slowly burned away.
O.armor = O.armor.setRating(fire = 50)
O.fire_act(10000, 1000 * delta_time)
else if (isliving(thing))
. = 1
var/mob/living/L = thing
if(L.movement_type & FLYING)
return //YOU'RE FLYING OVER IT
var/buckle_check = L.buckling
if(!buckle_check)
buckle_check = L.buckled
if(isobj(buckle_check))
var/obj/O = buckle_check
if(O.resistance_flags & LAVA_PROOF)
return
else if(isliving(buckle_check))
var/mob/living/live = buckle_check
if("lava" in live.weather_immunities)
return
if(!L.on_fire)
L.update_fire()
if(iscarbon(L))
var/mob/living/carbon/C = L
var/obj/item/clothing/S = C.get_item_by_slot(ITEM_SLOT_OCLOTHING)
var/obj/item/clothing/H = C.get_item_by_slot(ITEM_SLOT_HEAD)
if(S && H && S.clothing_flags & LAVAPROTECT && H.clothing_flags & LAVAPROTECT)
return
if("lava" in L.weather_immunities)
return
L.adjustFireLoss(20 * delta_time)
if(L) //mobs turning into object corpses could get deleted here.
L.adjust_fire_stacks(20 * delta_time)
L.ignite_mob()
////////////////////////////////////////////////////////////////////////////////////
//-------------------------------Toxic water lava---------------------------------//
////////////////////////////////////////////////////////////////////////////////////
/datum/component/lava/toxic/apply_damage(thing, delta_time)
. = 0
if(isobj(thing)) //objects are unaffected for now
return
else if (isliving(thing))
. = 1
var/mob/living/L = thing
if(L.movement_type & (FLYING|FLOATING))
return //YOU'RE FLYING OVER IT
if(HAS_TRAIT(L,TRAIT_SULPH_PIT_IMMUNE))
return
var/buckle_check = L.buckling
if(!buckle_check)
buckle_check = L.buckled
if(isobj(buckle_check))
var/obj/O = buckle_check
if(O.resistance_flags & ACID_PROOF)
return
else if(isliving(buckle_check))
var/mob/living/live = buckle_check
if(live.movement_type & (FLYING|FLOATING))
return
if(HAS_TRAIT(live, TRAIT_SULPH_PIT_IMMUNE))
return
if(ishuman(L))
var/mob/living/carbon/human/humie = L
var/chance = (100 - humie.getarmor(null,BIO)) * 0.33
if(isipc(humie) && prob(chance))
humie.adjustFireLoss(15)
to_chat(humie,span_danger("the sulphuric solution burns and singes into your plating!"))
return
if(prob((chance * 0.5) + 10))
humie.acid_act(15,15)
if(HAS_TRAIT(L,TRAIT_TOXIMMUNE) || HAS_TRAIT(L,TRAIT_TOXINLOVER))
return
humie.reagents.add_reagent(/datum/reagent/toxic_metabolities, 2)
else if(prob(25))
L.acid_act(5,7.5)
////////////////////////////////////////////////////////////////////////////////////
//----------------------------Plasma river lava-----------------------------------//
////////////////////////////////////////////////////////////////////////////////////
/datum/component/lava/plasma/apply_damage(thing, delta_time)
. = 0
if(isobj(thing))
var/obj/O = thing
if((O.resistance_flags & (FREEZE_PROOF)) || O.throwing)
return
else if (isliving(thing))
. = 1
var/mob/living/L = thing
if(L.movement_type & FLYING)
return //YOU'RE FLYING OVER IT
if(WEATHER_SNOW in L.weather_immunities)
return
var/buckle_check = L.buckling
if(!buckle_check)
buckle_check = L.buckled
if(isobj(buckle_check))
var/obj/O = buckle_check
if(O.resistance_flags & FREEZE_PROOF)
return
else if(isliving(buckle_check))
var/mob/living/live = buckle_check
if(WEATHER_SNOW in live.weather_immunities)
return
L.adjustFireLoss(2)
if(L)
L.adjust_fire_stacks(20) //dipping into a stream of plasma would probably make you more flammable than usual
L.adjust_bodytemperature(-rand(50,65)) //its cold, man
if(ishuman(L))//are they a carbon?
var/list/plasma_parts = list()//a list of the organic parts to be turned into plasma limbs
var/list/robo_parts = list()//keep a reference of robotic parts so we know if we can turn them into a plasmaman
var/mob/living/carbon/human/PP = L
var/datum/species/S = PP.dna.species
if(istype(S, /datum/species/plasmaman) || (S.inherent_biotypes & MOB_ROBOTIC)) //ignore plasmamen/robotic species
return
for(var/BP in PP.bodyparts)
var/obj/item/bodypart/NN = BP
if(NN.status == BODYPART_ROBOTIC)
robo_parts += NN
if(NN.body_zone == BODY_ZONE_HEAD) //don't add the head to the list, just transform them into an plasmaman when it's the only thing left
return
if(NN.status == BODYPART_ORGANIC && !(NN.species_id == "plasmaman" || NN.species_id == "husk")) //getting every organic, non-plasmaman limb (augments/androids are immune to this)
plasma_parts += NN
if(prob(35)) //checking if the delay is over & if the victim actually has any parts to nom
PP.adjustToxLoss(15)
PP.adjustFireLoss(25)
if(length(plasma_parts))
var/obj/item/bodypart/NB = pick(plasma_parts) //using the above-mentioned list to get a choice of limbs to replace
playsound(PP, 'sound/effects/wounds/sizzle2.ogg', 80, TRUE)
if(PP.stat != DEAD)
PP.emote("scream")
PP.visible_message(span_warning("[L] screams in pain as [L.p_their()] [NB] melts down to the bone!"), span_userdanger("You scream out in pain as your [NB] melts down to the bone, leaving an eerie plasma-like glow where flesh used to be!"))
else
PP.visible_message(span_warning("[L]'s [NB] melts down to the bone!"))
var/obj/item/bodypart/replacement_part = new NB.type
replacement_part.species_id = "plasmaman"
replacement_part.original_owner = "plasma river"
replacement_part.replace_limb(PP)
qdel(NB)
else if(!length(robo_parts)) //a person with no potential organic limbs left AND no robotic limbs, time to turn them into a plasmaman
PP.ignite_mob()
PP.cure_husk(BURN) //cure the probable husk first
PP.set_species(/datum/species/plasmaman)
PP.regenerate_icons()
PP.visible_message(span_warning("[L] bursts into a brilliant purple flame as [L.p_their()] entire body is that of a skeleton!"), \
span_userdanger("Your senses numb as all of your remaining flesh is turned into a purple slurry, sloshing off your body and leaving only your bones to show in a vibrant purple!"))

View File

@@ -195,30 +195,23 @@ Temperature: 126.85 °C (400 K)
planetary_atmos = TRUE
baseturfs = /turf/open/water/toxic_pit
/turf/open/water/toxic_pit/Entered(atom/movable/AM)
/turf/open/water/toxic_pit/Initialize(mapload)
. = ..()
if(!ishuman(AM))
return
AddComponent(/datum/component/lava/toxic)
var/mob/living/carbon/human/humie = AM
var/chance = (100 - humie.getarmor(null,BIO)) * 0.33
/turf/open/water/toxic_pit/rcd_vals(mob/user, obj/item/construction/rcd/the_rcd)
switch(the_rcd.construction_mode)
if(RCD_FLOORWALL)
return list("mode" = RCD_FLOORWALL, "delay" = 0, "cost" = 3)
return FALSE
if(AM.movement_type & (FLYING|FLOATING) || !AM.has_gravity() || HAS_TRAIT(AM,TRAIT_SULPH_PIT_IMMUNE))
return
if(isipc(humie) && prob(chance))
humie.adjustFireLoss(33)
to_chat(humie,span_danger("the sulphuric solution burns and singes into your plating!"))
return
if(HAS_TRAIT(humie,TRAIT_TOXIMMUNE) || HAS_TRAIT(humie,TRAIT_TOXINLOVER))
return
if(prob(chance * 0.33))
humie.reagents.add_reagent(/datum/reagent/toxic_metabolities,7.5)
if(prob((chance * 0.15 ) + 10 ))
humie.acid_act(5,7.5)
/turf/open/water/toxic_pit/rcd_act(mob/user, obj/item/construction/rcd/the_rcd, passed_mode)
switch(passed_mode)
if(RCD_FLOORWALL)
to_chat(user, span_notice("You build a floor."))
place_on_top(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
return TRUE
return FALSE
/turf/open/water/safe/jungle
initial_gas_mix = JUNGLELAND_DEFAULT_ATMOS
@@ -232,28 +225,6 @@ Temperature: 126.85 °C (400 K)
planetary_atmos = TRUE
baseturfs = /turf/open/water/deep_toxic_pit
/turf/open/water/deep_toxic_pit/Entered(atom/movable/AM)
. = ..()
if(!ishuman(AM))
return
var/mob/living/carbon/human/humie = AM
if(AM.movement_type & (FLYING|FLOATING) || !AM.has_gravity())
return
if(isipc(humie))
humie.adjustFireLoss(33)
to_chat(humie,span_danger("the sulphuric solution burns and singes into your plating!"))
return
if(HAS_TRAIT(humie,TRAIT_TOXIMMUNE) || HAS_TRAIT(humie,TRAIT_TOXINLOVER))
return
humie.reagents.add_reagent(/datum/reagent/toxic_metabolities,15)
humie.adjustFireLoss(33)
humie.acid_act(15,15)
/turf/open/floor/wood/jungle
initial_gas_mix = JUNGLELAND_DEFAULT_ATMOS