mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 21:18:37 +01:00
[MIRROR] Process procs now properly utilize deltatime when implementing rates, timers and probabilities (#709)
* Process procs now properly utilize deltatime when implementing rates, timers and probabilities (#52981) * Process procs now properly use deltatime when implementing rates, timers and probabilities * Review fixes * Geiger counters cleanup Made hardsuit geiger code more similar to geiger counter code Geiger counters are more responsive now * Moved SS*_DT defines to subsystems.dm * Rebase fix * Redefined the SS*_DT defines to use the subsystem wait vars * Implemented suggested changes by @AnturK * Commented /datum/proc/process about the deltatime stuff * Send delta_time as a process parameter instead of the defines Also DTfied acid_processing * Dtfied new acid component * Process procs now properly utilize deltatime when implementing rates, timers and probabilities Co-authored-by: Donkie <daniel.cf.hultgren@gmail.com>
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
var/datum/looping_sound/acid/sizzle
|
||||
/// Used exclusively for melting turfs. TODO: Move integrity to the atom level so that this can be dealt with there.
|
||||
var/parent_integrity = 30
|
||||
/// How far the acid melting of turfs has progressed
|
||||
var/stage = 0
|
||||
/// The proc used to handle the parent [/atom] when processing. TODO: Unify damage and resistance flags so that this doesn't need to exist!
|
||||
var/datum/callback/process_effect
|
||||
|
||||
@@ -94,25 +96,25 @@
|
||||
|
||||
|
||||
/// Handles the slow corrosion of the parent [/atom].
|
||||
/datum/component/acid/process()
|
||||
process_effect?.InvokeAsync()
|
||||
/datum/component/acid/process(delta_time)
|
||||
process_effect?.InvokeAsync(delta_time)
|
||||
if(QDELING(src)) //The process effect deals damage, and on turfs diminishes the acid volume, potentially destroying the component. Let's not destroy it twice.
|
||||
return
|
||||
set_volume(acid_volume - (ACID_DECAY_BASE + (ACID_DECAY_SCALING*round(sqrt(acid_volume)))))
|
||||
set_volume(acid_volume - (ACID_DECAY_BASE + (ACID_DECAY_SCALING*round(sqrt(acid_volume)))) * delta_time)
|
||||
|
||||
/// Handles processing on a [/obj].
|
||||
/datum/component/acid/proc/process_obj(obj/target)
|
||||
/datum/component/acid/proc/process_obj(obj/target, delta_time)
|
||||
if(target.resistance_flags & ACID_PROOF)
|
||||
return
|
||||
target.take_damage(min(1 + round(sqrt(acid_power * acid_volume)*0.3), OBJ_ACID_DAMAGE_MAX), BURN, ACID, 0)
|
||||
target.take_damage(min(1 + round(sqrt(acid_power * acid_volume)*0.3), OBJ_ACID_DAMAGE_MAX) * delta_time, BURN, ACID, 0)
|
||||
|
||||
/// Handles processing on a [/mob/living].
|
||||
/datum/component/acid/proc/process_mob(mob/living/target)
|
||||
target.acid_act(acid_power, acid_volume)
|
||||
/datum/component/acid/proc/process_mob(mob/living/target, delta_time)
|
||||
target.acid_act(acid_power, acid_volume * delta_time)
|
||||
|
||||
/// Handles processing on a [/turf].
|
||||
/datum/component/acid/proc/process_turf(turf/target_turf)
|
||||
var/acid_used = min(acid_volume * 0.05, 20)
|
||||
/datum/component/acid/proc/process_turf(turf/target_turf, delta_time)
|
||||
var/acid_used = min(acid_volume * 0.05, 20) * delta_time
|
||||
var/applied_targets = 0
|
||||
for(var/am in target_turf)
|
||||
var/atom/movable/target_movable = am
|
||||
@@ -126,19 +128,22 @@
|
||||
if(acid_power < ACID_POWER_MELT_TURF)
|
||||
return
|
||||
|
||||
switch(parent_integrity--)
|
||||
if(-INFINITY to 0)
|
||||
target_turf.visible_message("<span class='warning'>[target_turf] collapses under its own weight into a puddle of goop and undigested debris!</span>")
|
||||
target_turf.acid_melt()
|
||||
if(0 to 4)
|
||||
target_turf.visible_message("<span class='warning'>[target_turf] begins to crumble under the acid!</span>")
|
||||
if(4 to 8)
|
||||
target_turf.visible_message("<span class='warning'>[target_turf] is struggling to withstand the acid!</span>")
|
||||
if(8 to 16)
|
||||
target_turf.visible_message("<span class='warning'>[target_turf] is being melted by the acid!</span>")
|
||||
if(16 to 24)
|
||||
target_turf.visible_message("<span class='warning'>[target_turf] is holding up against the acid!</span>")
|
||||
|
||||
parent_integrity -= delta_time
|
||||
if(parent_integrity <= 0)
|
||||
target_turf.visible_message("<span class='warning'>[target_turf] collapses under its own weight into a puddle of goop and undigested debris!</span>")
|
||||
target_turf.acid_melt()
|
||||
else if(parent_integrity <= 4 && stage <= 3)
|
||||
target_turf.visible_message("<span class='warning'>[target_turf] begins to crumble under the acid!</span>")
|
||||
stage = 4
|
||||
else if(parent_integrity <= 8 && stage <= 2)
|
||||
target_turf.visible_message("<span class='warning'>[target_turf] is struggling to withstand the acid!</span>")
|
||||
stage = 3
|
||||
else if(parent_integrity <= 16 && stage <= 1)
|
||||
target_turf.visible_message("<span class='warning'>[target_turf] is being melted by the acid!</span>")
|
||||
stage = 2
|
||||
else if(parent_integrity <= 24 && stage == 0)
|
||||
target_turf.visible_message("<span class='warning'>[target_turf] is holding up against the acid!</span>")
|
||||
stage = 1
|
||||
|
||||
/// Used to maintain the acid overlay on the parent [/atom].
|
||||
/datum/component/acid/proc/on_update_overlays(atom/parent_atom, list/overlays)
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
/datum/component/embedded/UnregisterFromParent()
|
||||
UnregisterSignal(parent, list(COMSIG_MOVABLE_MOVED, COMSIG_CARBON_EMBED_RIP, COMSIG_CARBON_EMBED_REMOVAL))
|
||||
|
||||
/datum/component/embedded/process()
|
||||
/datum/component/embedded/process(delta_time)
|
||||
var/mob/living/carbon/victim = parent
|
||||
|
||||
if(!victim || !limb) // in case the victim and/or their limbs exploded (say, due to a sticky bomb)
|
||||
@@ -132,7 +132,7 @@
|
||||
return
|
||||
|
||||
var/damage = weapon.w_class * pain_mult
|
||||
var/pain_chance_current = pain_chance
|
||||
var/pain_chance_current = DT_PROB_RATE(pain_chance / 100, delta_time) * 100
|
||||
if(pain_stam_pct && HAS_TRAIT_FROM(victim, TRAIT_INCAPACITATED, STAMINA)) //if it's a less-lethal embed, give them a break if they're already stamcritted
|
||||
pain_chance_current *= 0.2
|
||||
damage *= 0.5
|
||||
@@ -143,7 +143,7 @@
|
||||
limb.receive_damage(brute=(1-pain_stam_pct) * damage, stamina=pain_stam_pct * damage, wound_bonus = CANT_WOUND)
|
||||
to_chat(victim, "<span class='userdanger'>[weapon] embedded in your [limb.name] hurts!</span>")
|
||||
|
||||
var/fall_chance_current = fall_chance
|
||||
var/fall_chance_current = DT_PROB_RATE(fall_chance / 100, delta_time) * 100
|
||||
if(victim.mobility_flags & ~MOBILITY_STAND)
|
||||
fall_chance_current *= 0.2
|
||||
|
||||
|
||||
@@ -170,26 +170,26 @@
|
||||
break
|
||||
|
||||
///Called on SSmood process
|
||||
/datum/component/mood/process()
|
||||
/datum/component/mood/process(delta_time)
|
||||
switch(mood_level)
|
||||
if(1)
|
||||
setSanity(sanity-0.3, SANITY_INSANE)
|
||||
setSanity(sanity-0.3*delta_time, SANITY_INSANE)
|
||||
if(2)
|
||||
setSanity(sanity-0.15, SANITY_INSANE)
|
||||
setSanity(sanity-0.15*delta_time, SANITY_INSANE)
|
||||
if(3)
|
||||
setSanity(sanity-0.1, SANITY_CRAZY)
|
||||
setSanity(sanity-0.1*delta_time, SANITY_CRAZY)
|
||||
if(4)
|
||||
setSanity(sanity-0.05, SANITY_UNSTABLE)
|
||||
setSanity(sanity-0.05*delta_time, SANITY_UNSTABLE)
|
||||
if(5)
|
||||
setSanity(sanity, SANITY_UNSTABLE) //This makes sure that mood gets increased should you be below the minimum.
|
||||
if(6)
|
||||
setSanity(sanity+0.2, SANITY_UNSTABLE)
|
||||
setSanity(sanity+0.2*delta_time, SANITY_UNSTABLE)
|
||||
if(7)
|
||||
setSanity(sanity+0.3, SANITY_UNSTABLE)
|
||||
setSanity(sanity+0.3*delta_time, SANITY_UNSTABLE)
|
||||
if(8)
|
||||
setSanity(sanity+0.4, SANITY_NEUTRAL, SANITY_MAXIMUM)
|
||||
setSanity(sanity+0.4*delta_time, SANITY_NEUTRAL, SANITY_MAXIMUM)
|
||||
if(9)
|
||||
setSanity(sanity+0.6, SANITY_NEUTRAL, SANITY_MAXIMUM)
|
||||
setSanity(sanity+0.6*delta_time, SANITY_NEUTRAL, SANITY_MAXIMUM)
|
||||
HandleNutrition()
|
||||
|
||||
///Sets sanity to the specified amount and applies effects.
|
||||
|
||||
@@ -109,9 +109,9 @@
|
||||
else
|
||||
adjust_nanites(null, amount) //just add to the nanite volume
|
||||
|
||||
/datum/component/nanites/process()
|
||||
/datum/component/nanites/process(delta_time)
|
||||
if(!IS_IN_STASIS(host_mob))
|
||||
adjust_nanites(null, regen_rate + (SSresearch.science_tech.researched_nodes["nanite_harmonic"] ? HARMONIC_REGEN_BOOST : 0))
|
||||
adjust_nanites(null, (regen_rate + (SSresearch.science_tech.researched_nodes["nanite_harmonic"] ? HARMONIC_REGEN_BOOST : 0)) * delta_time)
|
||||
add_research()
|
||||
for(var/X in programs)
|
||||
var/datum/nanite_program/NP = X
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
master.remove_filter("rad_glow")
|
||||
return ..()
|
||||
|
||||
/datum/component/radioactive/process()
|
||||
if(!prob(50))
|
||||
/datum/component/radioactive/process(delta_time)
|
||||
if(!DT_PROB(50, delta_time))
|
||||
return
|
||||
radiation_pulse(parent, strength, RAD_DISTANCE_COEFFICIENT*2, FALSE, can_contaminate)
|
||||
if(!hl3_release_date)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
START_PROCESSING(SSprocessing, src)
|
||||
|
||||
/datum/component/rot/process()
|
||||
/datum/component/rot/process(delta_time)
|
||||
var/atom/A = parent
|
||||
|
||||
var/turf/open/T = get_turf(A)
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
var/datum/gas_mixture/stank = new
|
||||
ADD_GAS(/datum/gas/miasma, stank.gases)
|
||||
stank.gases[/datum/gas/miasma][MOLES] = amount
|
||||
stank.gases[/datum/gas/miasma][MOLES] = amount * delta_time
|
||||
stank.temperature = BODYTEMP_NORMAL // otherwise we have gas below 2.7K which will break our lag generator
|
||||
T.assume_air(stank)
|
||||
T.air_update_turf()
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
else
|
||||
user_by_item -= source
|
||||
|
||||
/datum/element/earhealing/process()
|
||||
/datum/element/earhealing/process(delta_time)
|
||||
for(var/i in user_by_item)
|
||||
var/mob/living/carbon/user = user_by_item[i]
|
||||
var/obj/item/organ/ears/ears = user.getorganslot(ORGAN_SLOT_EARS)
|
||||
if(!ears || HAS_TRAIT_NOT_FROM(user, TRAIT_DEAF, EAR_DAMAGE))
|
||||
continue
|
||||
ears.deaf = max(ears.deaf - 0.25, (ears.damage < ears.maxHealth ? 0 : 1)) // Do not clear deafness if our ears are too damaged
|
||||
ears.damage = max(ears.damage - 0.025, 0)
|
||||
ears.deaf = max(ears.deaf - 0.25 * delta_time, (ears.damage < ears.maxHealth ? 0 : 1)) // Do not clear deafness if our ears are too damaged
|
||||
ears.damage = max(ears.damage - 0.025 * delta_time, 0)
|
||||
CHECK_TICK
|
||||
|
||||
@@ -41,12 +41,12 @@
|
||||
STOP_PROCESSING(SSradiation, src)
|
||||
..()
|
||||
|
||||
/datum/radiation_wave/process()
|
||||
/datum/radiation_wave/process(delta_time)
|
||||
master_turf = get_step(master_turf, move_dir)
|
||||
if(!master_turf)
|
||||
qdel(src)
|
||||
return
|
||||
steps++
|
||||
steps += delta_time
|
||||
var/list/atoms = get_rad_atoms()
|
||||
|
||||
var/strength
|
||||
|
||||
@@ -75,14 +75,14 @@
|
||||
/datum/quirk/proc/post_add() //for text, disclaimers etc. given after you spawn in with the trait
|
||||
/datum/quirk/proc/on_transfer() //code called when the trait is transferred to a new mob
|
||||
|
||||
/datum/quirk/process()
|
||||
/datum/quirk/process(delta_time)
|
||||
if(QDELETED(quirk_holder))
|
||||
quirk_holder = null
|
||||
qdel(src)
|
||||
return
|
||||
if(quirk_holder.stat == DEAD)
|
||||
return
|
||||
on_process()
|
||||
on_process(delta_time)
|
||||
|
||||
/**
|
||||
* get_quirk_string() is used to get a printable string of all the quirk traits someone has for certain criteria
|
||||
|
||||
@@ -37,18 +37,18 @@
|
||||
lose_text = "<span class='danger'>You no longer feel like drinking would ease your pain.</span>"
|
||||
medical_record_text = "Patient has unusually efficient liver metabolism and can slowly regenerate wounds by drinking alcoholic beverages."
|
||||
|
||||
/datum/quirk/drunkhealing/on_process()
|
||||
/datum/quirk/drunkhealing/on_process(delta_time)
|
||||
var/mob/living/carbon/C = quirk_holder
|
||||
switch(C.drunkenness)
|
||||
if (6 to 40)
|
||||
C.adjustBruteLoss(-0.1, FALSE)
|
||||
C.adjustFireLoss(-0.05, FALSE)
|
||||
C.adjustBruteLoss(-0.1*delta_time, FALSE)
|
||||
C.adjustFireLoss(-0.05*delta_time, FALSE)
|
||||
if (41 to 60)
|
||||
C.adjustBruteLoss(-0.4, FALSE)
|
||||
C.adjustFireLoss(-0.2, FALSE)
|
||||
C.adjustBruteLoss(-0.4*delta_time, FALSE)
|
||||
C.adjustFireLoss(-0.2*delta_time, FALSE)
|
||||
if (61 to INFINITY)
|
||||
C.adjustBruteLoss(-0.8, FALSE)
|
||||
C.adjustFireLoss(-0.4, FALSE)
|
||||
C.adjustBruteLoss(-0.8*delta_time, FALSE)
|
||||
C.adjustFireLoss(-0.4*delta_time, FALSE)
|
||||
|
||||
/datum/quirk/empath
|
||||
name = "Empath"
|
||||
@@ -126,8 +126,8 @@
|
||||
mood_quirk = TRUE
|
||||
medical_record_text = "Patient demonstrates constant euthymia irregular for environment. It's a bit much, to be honest."
|
||||
|
||||
/datum/quirk/jolly/on_process()
|
||||
if(prob(0.05))
|
||||
/datum/quirk/jolly/on_process(delta_time)
|
||||
if(DT_PROB(0.05, delta_time))
|
||||
SEND_SIGNAL(quirk_holder, COMSIG_ADD_MOOD_EVENT, "jolly", /datum/mood_event/jolly)
|
||||
|
||||
/datum/quirk/light_step
|
||||
|
||||
@@ -32,13 +32,13 @@
|
||||
medical_record_text = "Patient requires regular treatment for blood loss due to low production of blood."
|
||||
hardcore_value = 8
|
||||
|
||||
/datum/quirk/blooddeficiency/on_process()
|
||||
/datum/quirk/blooddeficiency/on_process(delta_time)
|
||||
var/mob/living/carbon/human/H = quirk_holder
|
||||
if(NOBLOOD in H.dna.species.species_traits) //can't lose blood if your species doesn't have any
|
||||
return
|
||||
else
|
||||
if (H.blood_volume > (BLOOD_VOLUME_SAFE - 25)) // just barely survivable without treatment
|
||||
H.blood_volume -= 0.275
|
||||
H.blood_volume -= 0.275 * delta_time
|
||||
|
||||
/datum/quirk/blindness
|
||||
name = "Blind"
|
||||
@@ -93,10 +93,10 @@
|
||||
|
||||
to_chat(quirk_holder, "<span class='boldnotice'>There is a bottle of mannitol pills [where] to keep you alive until you can secure a supply of medication. Don't rely on it too much!</span>")
|
||||
|
||||
/datum/quirk/brainproblems/on_process()
|
||||
/datum/quirk/brainproblems/on_process(delta_time)
|
||||
if(HAS_TRAIT(quirk_holder, TRAIT_TUMOR_SUPPRESSED))
|
||||
return
|
||||
quirk_holder.adjustOrganLoss(ORGAN_SLOT_BRAIN, 0.2)
|
||||
quirk_holder.adjustOrganLoss(ORGAN_SLOT_BRAIN, 0.2 * delta_time)
|
||||
|
||||
/datum/quirk/deafness
|
||||
name = "Deaf"
|
||||
@@ -119,8 +119,8 @@
|
||||
mood_quirk = TRUE
|
||||
hardcore_value = 1
|
||||
|
||||
/datum/quirk/depression/on_process()
|
||||
if(prob(0.05))
|
||||
/datum/quirk/depression/on_process(delta_time)
|
||||
if(DT_PROB(0.05, delta_time))
|
||||
SEND_SIGNAL(quirk_holder, COMSIG_ADD_MOOD_EVENT, "depression_mild", /datum/mood_event/depression_mild)
|
||||
|
||||
/datum/quirk/family_heirloom
|
||||
@@ -462,11 +462,11 @@
|
||||
medical_record_text = "Patient suffers from acute Reality Dissociation Syndrome and experiences vivid hallucinations."
|
||||
hardcore_value = 6
|
||||
|
||||
/datum/quirk/insanity/on_process()
|
||||
/datum/quirk/insanity/on_process(delta_time)
|
||||
if(quirk_holder.has_reagent(/datum/reagent/toxin/mindbreaker, needs_metabolizing = TRUE))
|
||||
quirk_holder.hallucination = 0
|
||||
return
|
||||
if(prob(2)) //we'll all be mad soon enough
|
||||
if(DT_PROB(2, delta_time)) //we'll all be mad soon enough
|
||||
madness()
|
||||
|
||||
/datum/quirk/insanity/proc/madness()
|
||||
@@ -495,18 +495,18 @@
|
||||
/datum/quirk/social_anxiety/remove()
|
||||
UnregisterSignal(quirk_holder, list(COMSIG_MOB_EYECONTACT, COMSIG_MOB_EXAMINATE))
|
||||
|
||||
/datum/quirk/social_anxiety/on_process()
|
||||
/datum/quirk/social_anxiety/on_process(delta_time)
|
||||
var/nearby_people = 0
|
||||
for(var/mob/living/carbon/human/H in oview(3, quirk_holder))
|
||||
if(H.client)
|
||||
nearby_people++
|
||||
var/mob/living/carbon/human/H = quirk_holder
|
||||
if(prob(2 + nearby_people))
|
||||
if(DT_PROB(2 + nearby_people, delta_time))
|
||||
H.stuttering = max(3, H.stuttering)
|
||||
else if(prob(min(3, nearby_people)) && !H.silent)
|
||||
else if(DT_PROB(min(3, nearby_people), delta_time) && !H.silent)
|
||||
to_chat(H, "<span class='danger'>You retreat into yourself. You <i>really</i> don't feel up to talking.</span>")
|
||||
H.silent = max(10, H.silent)
|
||||
else if(prob(0.5) && dumb_thing)
|
||||
else if(DT_PROB(0.5, delta_time) && dumb_thing)
|
||||
to_chat(H, "<span class='userdanger'>You think of a dumb thing you said a long time ago and scream internally.</span>")
|
||||
dumb_thing = FALSE //only once per life
|
||||
if(prob(1))
|
||||
@@ -704,7 +704,7 @@
|
||||
dogtag.display = display
|
||||
human_holder.equip_in_one_of_slots(dogtag, slots , qdel_on_fail = TRUE)
|
||||
|
||||
/datum/quirk/allergic/on_process()
|
||||
/datum/quirk/allergic/on_process(delta_time)
|
||||
. = ..()
|
||||
if(!iscarbon(quirk_holder))
|
||||
return
|
||||
@@ -718,9 +718,9 @@
|
||||
instantiated_med.reagent_removal_skip_list |= ALLERGIC_REMOVAL_SKIP
|
||||
return //intentionally stops the entire proc so we avoid the organ damage after the loop
|
||||
instantiated_med.reagent_removal_skip_list -= ALLERGIC_REMOVAL_SKIP
|
||||
carbon_quirk_holder.adjustToxLoss(3)
|
||||
carbon_quirk_holder.reagents.add_reagent(/datum/reagent/toxin/histamine,3)
|
||||
if(prob(10))
|
||||
carbon_quirk_holder.adjustToxLoss(3 * delta_time)
|
||||
carbon_quirk_holder.reagents.add_reagent(/datum/reagent/toxin/histamine, 3 * delta_time)
|
||||
if(DT_PROB(10, delta_time))
|
||||
carbon_quirk_holder.vomit()
|
||||
carbon_quirk_holder.adjustOrganLoss(pick(ORGAN_SLOT_BRAIN,ORGAN_SLOT_APPENDIX,ORGAN_SLOT_LUNGS,ORGAN_SLOT_HEART,ORGAN_SLOT_LIVER,ORGAN_SLOT_STOMACH),10)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user