/mob/living var/instability = 0 var/last_instability_event = null // most recent world.time that something bad happened due to instability. // Proc: adjust_instability() // Parameters: 0 // Description: Does nothing, because inheritence. /mob/living/proc/adjust_instability() return // Proc: adjust_instability() // Parameters: 1 (amount - how much instability to give) // Description: Adds or subtracks instability to the mob, then updates the hud. /mob/living/carbon/human/adjust_instability(var/amount) instability = min(max(instability + amount, 0), 200) instability_update_hud() // Proc: instability_update_hud() // Parameters: 0 // Description: Sets the HUD icon to the correct state. /mob/living/carbon/human/proc/instability_update_hud() if(client && hud_used) switch(instability) if(0 to 10) wiz_instability_display.icon_state = "instability-1" if(11 to 30) wiz_instability_display.icon_state = "instability0" if(31 to 50) wiz_instability_display.icon_state = "instability1" if(51 to 100) wiz_instability_display.icon_state = "instability2" if(101 to 200) wiz_instability_display.icon_state = "instability3" // Proc: Life() // Parameters: 0 // Description: Makes instability tick along with Life(). /mob/living/carbon/human/Life() . = ..() handle_instability() // Proc: handle_instability() // Parameters: 0 // Description: Makes instability decay. instability_effects() handles the bad effects for having instability. It will also hold back // from causing bad effects more than one every ten seconds, to prevent sudden death from angry RNG. /mob/living/carbon/human/proc/handle_instability() instability = round(Clamp(instability, 0, 200)) instability_update_hud() //This should cushon against really bad luck. if(instability && last_instability_event < (world.time - 10 SECONDS) && prob(20)) instability_effects() switch(instability) if(1 to 10) adjust_instability(-2) if(11 to 20) adjust_instability(-4) if(21 to 30) adjust_instability(-6) if(31 to 40) adjust_instability(-8) if(41 to 50) adjust_instability(-10) if(51 to 100) adjust_instability(-20) if(101 to 200) adjust_instability(-40) /* [16:18:08] Sparks [16:18:10] Wormholes [16:18:16] Random spells firing off on their own [16:18:22] The possibilities are endless [16:19:00] Random objects phasing into reality, only to disappear again [16:19:05] Things briefly duplicating [16:20:56] Glass cracking, eventually breaking */ // Proc: instability_effects() // Parameters: 0 // Description: Does a variety of bad effects to the entity holding onto the instability, with more severe effects occuring if they have // a lot of instability. /mob/living/carbon/human/proc/instability_effects() if(instability) var/rng = 0 last_instability_event = world.time spawn(1) var/image/instability_flash = image('icons/obj/spells.dmi',"instability") overlays |= instability_flash sleep(4) overlays.Remove(instability_flash) qdel(instability_flash) radiate_instability() switch(instability) if(1 to 10) //Harmless return if(11 to 30) //Minor rng = rand(0,1) switch(rng) if(0) var/datum/effect/effect/system/spark_spread/sparks = PoolOrNew(/datum/effect/effect/system/spark_spread) sparks.set_up(5, 0, src) sparks.attach(loc) // var/datum/effect/effect/system/spark_spread/spark_system = PoolOrNew(/datum/effect/effect/system/spark_spread) // spark_system.set_up(5, 0, get_turf(src)) // spark_system.attach(src) sparks.start() visible_message("Electrical sparks manifest from nowhere around \the [src]!") qdel(sparks) if(1) return if(31 to 50) //Moderate rng = rand(0,8) switch(rng) if(0) apply_effect(instability * 0.5, IRRADIATE) if(1) return // visible_message("\The [src] suddenly collapses!", // "You suddenly feel very weak, and you fall down!") // Weaken(instability * 0.1) if(2) if(can_feel_pain()) apply_effect(instability * 0.5, AGONY) src << "You feel a sharp pain!" if(3) apply_effect(instability * 0.5, EYE_BLUR) src << "Your eyes start to get cloudy!" if(4) electrocute_act(instability * 0.3, "unstable energies") if(5) adjustFireLoss(instability * 0.2) //10 burn @ 50 instability src << "You feel your skin burn!" if(6) adjustBruteLoss(instability * 0.2) //10 brute @ 50 instability src << "You feel a sharp pain as an unseen force harms your body!" if(7) adjustToxLoss(instability * 0.2) //10 tox @ 50 instability if(8) safe_blink(src, range = 6) src << "You're teleported against your will!" if(51 to 100) //Severe rng = rand(0,8) switch(rng) if(0) apply_effect(instability * 0.7, IRRADIATE) if(1) // visible_message("\The [src] suddenly collapses!", // "You suddenly feel very light-headed, and faint!") // Paralyse(instability * 0.1) return if(2) if(can_feel_pain()) apply_effect(instability * 0.7, AGONY) src << "You feel an extremly angonizing pain from all over your body!" if(3) apply_effect(instability * 0.5, EYE_BLUR) src << "Your eyes start to get cloudy!" if(4) electrocute_act(instability * 0.5, "extremely unstable energies") if(5) fire_act() src << "You spontaneously combust!" if(6) adjustCloneLoss(instability * 0.05) //5 cloneloss @ 100 instability src << "You feel your body slowly degenerate." if(7) adjustToxLoss(instability * 0.25) //25 tox @ 100 instability if(101 to 200) //Lethal rng = rand(0,8) switch(rng) if(0) apply_effect(instability, IRRADIATE) if(1) visible_message("\The [src] suddenly collapses!", "You suddenly feel very light-headed, and faint!") Paralyse(instability * 0.1) if(2) if(can_feel_pain()) apply_effect(instability, AGONY) src << "You feel an extremly angonizing pain from all over your body!" if(3) apply_effect(instability, EYE_BLUR) src << "Your eyes start to get cloudy!" if(4) electrocute_act(instability, "extremely unstable energies") if(5) fire_act() src << "You spontaneously combust!" if(6) adjustCloneLoss(instability * 0.10) //5 cloneloss @ 100 instability src << "You feel your body slowly degenerate." if(7) adjustToxLoss(instability * 0.40) //25 tox @ 100 instability /mob/living/carbon/human/proc/radiate_instability() var/distance = round(sqrt(instability / 2)) if(instability <= 30) distance = 0 if(distance) for(var/mob/living/carbon/human/H in range(src, distance) ) if(H == src) // This instability is radiating away from them, so don't include them. continue var/radius = max(get_dist(H, src), 1) // People next to the source take a third of the instability. Further distance decreases the amount absorbed. var/outgoing_instability = (instability / 3) * ( 1 / (radius**2) ) // Energy armor like from the AMI RIG can protect from this. var/armor = getarmor(null, "energy") var/armor_factor = abs( (armor - 100) / 100) outgoing_instability = outgoing_instability * armor_factor H.adjust_instability(outgoing_instability) set_light(distance, distance * 2, l_color = "#C26DDE")