mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
Refactors genetic damage component to be a status effect (#74799)
## About The Pull Request The genetic damage component looked like a status effect, swam like a status effect, quacked like a status effect, but wasn't a status effect. Irradiated component is also guilty of this, but it has the excuse of also getting applied to items. This one only applies to mobs though, so... ## Why It's Good For The Game Easier to maintain code, that's about it. ## Changelog Not player facing.
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
#define GORILLA_MUTATION_CHANCE_PER_SECOND 0.25
|
||||
#define GORILLA_MUTATION_MINIMUM_DAMAGE 2500
|
||||
|
||||
/// Genetic damage, given by DNA consoles, will start to deal toxin damage
|
||||
/// past a certain threshold, and will go down consistently.
|
||||
/// Adding multiple of this component will increase the total damage.
|
||||
/// Can turn monkeys into gorillas.
|
||||
/datum/component/genetic_damage
|
||||
dupe_mode = COMPONENT_DUPE_UNIQUE
|
||||
|
||||
/// The total genetic damage on the mob
|
||||
var/total_damage = 0
|
||||
|
||||
/// The amount of genetic damage a mob can sustain before taking damage
|
||||
var/minimum_before_damage = 500
|
||||
|
||||
/// The amount of genetic damage to remove per second
|
||||
var/remove_per_second = 1 / 3
|
||||
|
||||
/// The amount of toxin damage to deal per second, if over the minimum before taking damage
|
||||
var/toxin_damage_per_second = 1 / 3
|
||||
|
||||
/datum/component/genetic_damage/Initialize(genetic_damage)
|
||||
if (!isliving(parent))
|
||||
return COMPONENT_INCOMPATIBLE
|
||||
|
||||
src.total_damage = genetic_damage
|
||||
|
||||
START_PROCESSING(SSprocessing, src)
|
||||
|
||||
/datum/component/genetic_damage/RegisterWithParent()
|
||||
RegisterSignal(parent, COMSIG_LIVING_HEALTHSCAN, PROC_REF(on_healthscan))
|
||||
|
||||
/datum/component/genetic_damage/UnregisterFromParent()
|
||||
UnregisterSignal(parent, COMSIG_LIVING_HEALTHSCAN)
|
||||
|
||||
/datum/component/genetic_damage/Destroy(force, silent)
|
||||
STOP_PROCESSING(SSprocessing, src)
|
||||
|
||||
return ..()
|
||||
|
||||
/datum/component/genetic_damage/InheritComponent(datum/component/genetic_damage/old_component)
|
||||
total_damage += old_component.total_damage
|
||||
|
||||
/datum/component/genetic_damage/process(seconds_per_tick)
|
||||
if (ismonkey(parent) && total_damage >= GORILLA_MUTATION_MINIMUM_DAMAGE && SPT_PROB(GORILLA_MUTATION_CHANCE_PER_SECOND, seconds_per_tick))
|
||||
var/mob/living/carbon/carbon_parent = parent
|
||||
carbon_parent.gorillize()
|
||||
qdel(src)
|
||||
return PROCESS_KILL
|
||||
|
||||
if (total_damage >= minimum_before_damage)
|
||||
var/mob/living/living_mob = parent
|
||||
living_mob.adjustToxLoss(toxin_damage_per_second * seconds_per_tick)
|
||||
|
||||
total_damage -= remove_per_second * seconds_per_tick
|
||||
if (total_damage <= 0)
|
||||
qdel(src)
|
||||
return PROCESS_KILL
|
||||
|
||||
/datum/component/genetic_damage/proc/on_healthscan(datum/source, list/render_list, advanced)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if (advanced)
|
||||
render_list += "<span class='alert ml-1'>Genetic damage: [round(total_damage / minimum_before_damage * 100, 0.1)]%</span>\n"
|
||||
else if (total_damage >= minimum_before_damage)
|
||||
render_list += "<span class='alert ml-1'>Severe genetic damage detected.</span>\n"
|
||||
else
|
||||
render_list += "<span class='alert ml-1'>Minor genetic damage detected.</span>\n"
|
||||
|
||||
#undef GORILLA_MUTATION_CHANCE_PER_SECOND
|
||||
#undef GORILLA_MUTATION_MINIMUM_DAMAGE
|
||||
@@ -0,0 +1,60 @@
|
||||
#define GORILLA_MUTATION_CHANCE_PER_SECOND 0.25
|
||||
#define GORILLA_MUTATION_MINIMUM_DAMAGE 2500
|
||||
|
||||
/datum/status_effect/genetic_damage
|
||||
id = "genetic_damage"
|
||||
alert_type = null
|
||||
status_type = STATUS_EFFECT_REFRESH // New effects will add to total_damage
|
||||
duration = -1
|
||||
tick_interval = 2 SECONDS
|
||||
on_remove_on_mob_delete = TRUE // Need to unregister from owner, be_replaced() would cause runtimes
|
||||
remove_on_fullheal = TRUE
|
||||
/// The total genetic damage accumulated on the mob
|
||||
var/total_damage = 0
|
||||
/// The amount of genetic damage a mob can sustain before taking toxin damage
|
||||
var/minimum_before_tox_damage = 500
|
||||
/// The amount of genetic damage to remove per second
|
||||
var/remove_per_second = 1 / 3
|
||||
/// The amount of toxin damage to deal per second, if over the minimum before taking damage
|
||||
var/toxin_damage_per_second = 1 / 3
|
||||
|
||||
/datum/status_effect/genetic_damage/on_creation(mob/living/new_owner, total_damage)
|
||||
. = ..()
|
||||
src.total_damage = total_damage
|
||||
RegisterSignal(new_owner, COMSIG_LIVING_HEALTHSCAN, PROC_REF(on_healthscan))
|
||||
|
||||
/datum/status_effect/genetic_damage/on_remove()
|
||||
. = ..()
|
||||
UnregisterSignal(owner, COMSIG_LIVING_HEALTHSCAN)
|
||||
|
||||
/datum/status_effect/genetic_damage/refresh(mob/living/owner, total_damage)
|
||||
. = ..()
|
||||
src.total_damage += total_damage
|
||||
|
||||
/datum/status_effect/genetic_damage/tick(seconds_per_tick, times_fired)
|
||||
if(ismonkey(owner) && total_damage >= GORILLA_MUTATION_MINIMUM_DAMAGE && SPT_PROB(GORILLA_MUTATION_CHANCE_PER_SECOND, seconds_per_tick))
|
||||
qdel(src)
|
||||
var/mob/living/carbon/carbon_owner = owner
|
||||
carbon_owner.gorillize()
|
||||
return
|
||||
|
||||
if(total_damage >= minimum_before_tox_damage)
|
||||
owner.adjustToxLoss(toxin_damage_per_second * seconds_per_tick)
|
||||
|
||||
total_damage -= remove_per_second * seconds_per_tick
|
||||
if(total_damage <= 0)
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
/datum/status_effect/genetic_damage/proc/on_healthscan(datum/source, list/render_list, advanced)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(advanced)
|
||||
render_list += "<span class='alert ml-1'>Genetic damage: [round(total_damage / minimum_before_tox_damage * 100, 0.1)]%</span>\n"
|
||||
else if(total_damage >= minimum_before_tox_damage)
|
||||
render_list += "<span class='alert ml-1'>Severe genetic damage detected.</span>\n"
|
||||
else
|
||||
render_list += "<span class='alert ml-1'>Minor genetic damage detected.</span>\n"
|
||||
|
||||
#undef GORILLA_MUTATION_CHANCE_PER_SECOND
|
||||
#undef GORILLA_MUTATION_MINIMUM_DAMAGE
|
||||
@@ -334,8 +334,8 @@
|
||||
data["subjectUF"] = scanner_occupant.dna.unique_features
|
||||
data["storage"]["occupant"] = tgui_occupant_mutations
|
||||
|
||||
var/datum/component/genetic_damage/genetic_damage = scanner_occupant.GetComponent(/datum/component/genetic_damage)
|
||||
data["subjectDamage"] = genetic_damage ? round((genetic_damage.total_damage / genetic_damage.minimum_before_damage) * 100, 0.1) : 0
|
||||
var/datum/status_effect/genetic_damage/genetic_damage = scanner_occupant.has_status_effect(/datum/status_effect/genetic_damage)
|
||||
data["subjectDamage"] = genetic_damage ? round((genetic_damage.total_damage / genetic_damage.minimum_before_tox_damage) * 100, 0.1) : 0
|
||||
else
|
||||
data["subjectName"] = null
|
||||
data["subjectStatus"] = null
|
||||
@@ -436,7 +436,7 @@
|
||||
scanner_occupant.dna.generate_dna_blocks()
|
||||
scramble_ready = world.time + SCRAMBLE_TIMEOUT
|
||||
to_chat(usr,span_notice("DNA scrambled."))
|
||||
scanner_occupant.AddComponent(/datum/component/genetic_damage, GENETIC_DAMAGE_STRENGTH_MULTIPLIER*50/(connected_scanner.damage_coeff ** 2))
|
||||
scanner_occupant.apply_status_effect(/datum/status_effect/genetic_damage, GENETIC_DAMAGE_STRENGTH_MULTIPLIER*50/(connected_scanner.damage_coeff ** 2))
|
||||
if(connected_scanner)
|
||||
connected_scanner.use_power(connected_scanner.active_power_usage)
|
||||
else
|
||||
@@ -560,7 +560,7 @@
|
||||
// Copy genome to scanner occupant and do some basic mutation checks as
|
||||
// we've increased the occupant genetic damage
|
||||
scanner_occupant.dna.mutation_index[path] = copytext(sequence, 1, genepos) + newgene + copytext(sequence, genepos + 1)
|
||||
scanner_occupant.AddComponent(/datum/component/genetic_damage, GENETIC_DAMAGE_STRENGTH_MULTIPLIER/connected_scanner.damage_coeff)
|
||||
scanner_occupant.apply_status_effect(/datum/status_effect/genetic_damage, GENETIC_DAMAGE_STRENGTH_MULTIPLIER/connected_scanner.damage_coeff)
|
||||
scanner_occupant.domutcheck()
|
||||
|
||||
// GUARD CHECK - Modifying genetics can lead to edge cases where the
|
||||
@@ -1692,7 +1692,7 @@
|
||||
COOLDOWN_START(src, enzyme_copy_timer, ENZYME_COPY_BASE_COOLDOWN)
|
||||
scanner_occupant.dna.unique_identity = buffer_slot["UI"]
|
||||
scanner_occupant.updateappearance(mutations_overlay_update=1)
|
||||
scanner_occupant.AddComponent(/datum/component/genetic_damage, damage_increase)
|
||||
scanner_occupant.apply_status_effect(/datum/status_effect/genetic_damage, damage_increase)
|
||||
scanner_occupant.domutcheck()
|
||||
return TRUE
|
||||
if("uf")
|
||||
@@ -1705,7 +1705,7 @@
|
||||
COOLDOWN_START(src, enzyme_copy_timer, ENZYME_COPY_BASE_COOLDOWN)
|
||||
scanner_occupant.dna.unique_features = buffer_slot["UF"]
|
||||
scanner_occupant.updateappearance(mutcolor_update=1, mutations_overlay_update=1)
|
||||
scanner_occupant.AddComponent(/datum/component/genetic_damage, damage_increase)
|
||||
scanner_occupant.apply_status_effect(/datum/status_effect/genetic_damage, damage_increase)
|
||||
scanner_occupant.domutcheck()
|
||||
return TRUE
|
||||
if("ue")
|
||||
@@ -1720,7 +1720,7 @@
|
||||
scanner_occupant.name = buffer_slot["name"]
|
||||
scanner_occupant.dna.unique_enzymes = buffer_slot["UE"]
|
||||
scanner_occupant.dna.blood_type = buffer_slot["blood_type"]
|
||||
scanner_occupant.AddComponent(/datum/component/genetic_damage, damage_increase)
|
||||
scanner_occupant.apply_status_effect(/datum/status_effect/genetic_damage, damage_increase)
|
||||
scanner_occupant.domutcheck()
|
||||
return TRUE
|
||||
if("mixed")
|
||||
@@ -1738,7 +1738,7 @@
|
||||
scanner_occupant.name = buffer_slot["name"]
|
||||
scanner_occupant.dna.unique_enzymes = buffer_slot["UE"]
|
||||
scanner_occupant.dna.blood_type = buffer_slot["blood_type"]
|
||||
scanner_occupant.AddComponent(/datum/component/genetic_damage, damage_increase)
|
||||
scanner_occupant.apply_status_effect(/datum/status_effect/genetic_damage, damage_increase)
|
||||
scanner_occupant.domutcheck()
|
||||
return TRUE
|
||||
|
||||
|
||||
+1
-1
@@ -912,7 +912,6 @@
|
||||
#include "code\datums\components\gags_recolorable.dm"
|
||||
#include "code\datums\components\gas_leaker.dm"
|
||||
#include "code\datums\components\geiger_sound.dm"
|
||||
#include "code\datums\components\genetic_damage.dm"
|
||||
#include "code\datums\components\gps.dm"
|
||||
#include "code\datums\components\grillable.dm"
|
||||
#include "code\datums\components\ground_sinking.dm"
|
||||
@@ -1403,6 +1402,7 @@
|
||||
#include "code\datums\status_effects\debuffs\drugginess.dm"
|
||||
#include "code\datums\status_effects\debuffs\drunk.dm"
|
||||
#include "code\datums\status_effects\debuffs\fire_stacks.dm"
|
||||
#include "code\datums\status_effects\debuffs\genetic_damage.dm"
|
||||
#include "code\datums\status_effects\debuffs\hallucination.dm"
|
||||
#include "code\datums\status_effects\debuffs\jitteriness.dm"
|
||||
#include "code\datums\status_effects\debuffs\pacifism.dm"
|
||||
|
||||
Reference in New Issue
Block a user