Fixing owner not being set in mutation/on_aquiring.

This commit is contained in:
Ghommie
2020-03-22 15:23:05 +01:00
parent 82cf7e584b
commit 3c2cb76792
15 changed files with 49 additions and 46 deletions
+184
View File
@@ -0,0 +1,184 @@
/datum/mutation
var/name
/datum/mutation/human
name = "mutation"
var/desc = "A mutation."
var/locked
var/quality
var/get_chance = 100
var/lowest_value = 256 * 8
var/text_gain_indication = ""
var/text_lose_indication = ""
var/list/mutable_appearance/visual_indicators = list()
var/obj/effect/proc_holder/spell/power
var/layer_used = MUTATIONS_LAYER //which mutation layer to use
var/list/species_allowed = list() //to restrict mutation to only certain species
var/health_req //minimum health required to acquire the mutation
var/limb_req //required limbs to acquire this mutation
var/time_coeff = 1 //coefficient for timed mutations
var/datum/dna/dna
var/mob/living/carbon/human/owner
var/instability = 0 //instability the holder gets when the mutation is not native
var/blocks = 4 //Amount of those big blocks with gene sequences
var/difficulty = 8 //Amount of missing sequences. Sometimes it removes an entire pair for 2 points
var/timed = FALSE //Boolean to easily check if we're going to self destruct
var/alias //'Mutation #49', decided every round to get some form of distinction between undiscovered mutations
var/scrambled = FALSE //Wheter we can read it if it's active. To avoid cheesing with mutagen
var/class //Decides player accesibility, sorta
//MUT_NORMAL - A mutation that can be activated and deactived by completing a sequence
//MUT_EXTRA - A mutation that is in the mutations tab, and can be given and taken away through though the DNA console. Has a 0 before it's name in the mutation section of the dna console
//MUT_OTHER Cannot be interacted with by players through normal means. I.E. wizards mutate
var/can_chromosome = CHROMOSOME_NONE //can we take chromosomes? 0: CHROMOSOME_NEVER never, 1:CHROMOSOME_NONE yeah, 2: CHROMOSOME_USED no, already have one
var/chromosome_name //purely cosmetic
var/modified = FALSE //ugly but we really don't want chromosomes and on_acquiring to overlap and apply double the powers
var/mutadone_proof = FALSE
//Chromosome stuff - set to -1 to prevent people from changing it. Example: It'd be a waste to decrease cooldown on mutism
var/stabilizer_coeff = 1 //genetic stability coeff
var/synchronizer_coeff = -1 //makes the mutation hurt the user less
var/power_coeff = -1 //boosts mutation strength
var/energy_coeff = -1 //lowers mutation cooldown
/datum/mutation/human/New(class_ = MUT_OTHER, timer, datum/mutation/human/copymut)
. = ..()
class = class_
if(timer)
addtimer(CALLBACK(src, .proc/remove), timer)
timed = TRUE
if(copymut && istype(copymut, /datum/mutation/human))
copy_mutation(copymut)
/datum/mutation/human/proc/on_acquiring(mob/living/carbon/human/H)
if(!H || !istype(H) || H.stat == DEAD || (src in H.dna.mutations))
return TRUE
if(species_allowed.len && !species_allowed.Find(H.dna.species.id))
return TRUE
if(health_req && H.health < health_req)
return TRUE
if(limb_req && !H.get_bodypart(limb_req))
return TRUE
owner = H
dna = H.dna
dna.mutations += src
if(text_gain_indication)
to_chat(H, text_gain_indication)
if(visual_indicators.len)
var/list/mut_overlay = list(get_visual_indicator())
if(H.overlays_standing[layer_used])
mut_overlay = H.overlays_standing[layer_used]
mut_overlay |= get_visual_indicator()
H.remove_overlay(layer_used)
H.overlays_standing[layer_used] = mut_overlay
H.apply_overlay(layer_used)
grant_spell()
if(!modified)
addtimer(CALLBACK(src, .proc/modify, 5)) //gonna want children calling ..() to run first
/datum/mutation/human/proc/get_visual_indicator()
return
/datum/mutation/human/proc/on_attack_hand(atom/target, proximity)
return
/datum/mutation/human/proc/on_ranged_attack(atom/target, mouseparams)
return
/datum/mutation/human/proc/on_move(atom/new_loc)
return
/datum/mutation/human/proc/on_life()
return
/datum/mutation/human/proc/on_losing(mob/living/carbon/human/owner)
if(owner && istype(owner) && (owner.dna.mutations.Remove(src)))
if(text_lose_indication && owner.stat != DEAD)
to_chat(owner, text_lose_indication)
if(visual_indicators.len)
var/list/mut_overlay = list()
if(owner.overlays_standing[layer_used])
mut_overlay = owner.overlays_standing[layer_used]
owner.remove_overlay(layer_used)
mut_overlay.Remove(get_visual_indicator(owner))
owner.overlays_standing[layer_used] = mut_overlay
owner.apply_overlay(layer_used)
if(power)
owner.RemoveSpell(power)
qdel(src)
return 0
return 1
/datum/mutation/human/proc/say_mod(message)
if(message)
return message
/datum/mutation/human/proc/get_spans()
return list()
/mob/living/carbon/proc/update_mutations_overlay()
return
/mob/living/carbon/human/update_mutations_overlay()
for(var/datum/mutation/human/CM in dna.mutations)
if(CM.species_allowed.len && !CM.species_allowed.Find(dna.species.id))
dna.force_lose(CM) //shouldn't have that mutation at all
continue
if(CM.visual_indicators.len)
var/list/mut_overlay = list()
if(overlays_standing[CM.layer_used])
mut_overlay = overlays_standing[CM.layer_used]
var/mutable_appearance/V = CM.get_visual_indicator()
if(!mut_overlay.Find(V)) //either we lack the visual indicator or we have the wrong one
remove_overlay(CM.layer_used)
for(var/mutable_appearance/MA in CM.visual_indicators[CM.type])
mut_overlay.Remove(MA)
mut_overlay |= V
overlays_standing[CM.layer_used] = mut_overlay
apply_overlay(CM.layer_used)
/datum/mutation/human/proc/modify() //called when a genome is applied so we can properly update some stats without having to remove and reapply the mutation from someone
if(modified || !power || !owner)
return
power.charge_max *= GET_MUTATION_ENERGY(src)
power.charge_counter *= GET_MUTATION_ENERGY(src)
modified = TRUE
/datum/mutation/human/proc/copy_mutation(datum/mutation/human/HM)
if(!HM)
return
chromosome_name = HM.chromosome_name
stabilizer_coeff = HM.stabilizer_coeff
synchronizer_coeff = HM.synchronizer_coeff
power_coeff = HM.power_coeff
energy_coeff = HM.energy_coeff
mutadone_proof = HM.mutadone_proof
can_chromosome = HM.can_chromosome
/datum/mutation/human/proc/remove_chromosome()
stabilizer_coeff = initial(stabilizer_coeff)
synchronizer_coeff = initial(synchronizer_coeff)
power_coeff = initial(power_coeff)
energy_coeff = initial(energy_coeff)
mutadone_proof = initial(mutadone_proof)
can_chromosome = initial(can_chromosome)
chromosome_name = null
/datum/mutation/human/proc/remove()
if(dna)
dna.force_lose(src)
else
qdel(src)
/datum/mutation/human/proc/grant_spell()
if(!ispath(power) || !owner)
return FALSE
power = new power()
power.action_background_icon_state = "bg_tech_blue_on"
power.panel = "Genetic"
owner.AddSpell(power)
return TRUE
+1 -1
View File
@@ -111,7 +111,7 @@
energy_coeff = 1
synchronizer_coeff = 1
/datum/mutation/human/void/on_life(mob/living/carbon/human/owner)
/datum/mutation/human/void/on_life()
if(!isturf(owner.loc))
return
if(prob((0.5+((100-dna.stability)/20))) * GET_MUTATION_SYNCHRONIZER(src)) //very rare, but enough to annoy you hopefully. +0.5 probability for every 10 points lost in stability
+2 -2
View File
@@ -36,7 +36,7 @@
if(!(type in visual_indicators))
visual_indicators[type] = list(mutable_appearance('icons/effects/genetics.dmi', "antenna", -FRONT_MUTATIONS_LAYER+1))//-MUTATIONS_LAYER+1
/datum/mutation/human/antenna/get_visual_indicator(mob/living/carbon/human/owner)
/datum/mutation/human/antenna/get_visual_indicator()
return visual_indicators[type][1]
/datum/mutation/human/mindreader
@@ -104,5 +104,5 @@
if(!(type in visual_indicators))
visual_indicators[type] = list(mutable_appearance('icons/effects/genetics.dmi', "antenna", -FRONT_MUTATIONS_LAYER+1))
/datum/mutation/human/mindreader/get_visual_indicator(mob/living/carbon/human/owner)
/datum/mutation/human/mindreader/get_visual_indicator()
return visual_indicators[type][1]
+5 -5
View File
@@ -9,7 +9,7 @@
synchronizer_coeff = 1
power_coeff = 1
/datum/mutation/human/epilepsy/on_life(mob/living/carbon/human/owner)
/datum/mutation/human/epilepsy/on_life()
if(prob(1 * GET_MUTATION_SYNCHRONIZER(src)) && owner.stat == CONSCIOUS)
owner.visible_message("<span class='danger'>[owner] starts having a seizure!</span>", "<span class='userdanger'>You have a seizure!</span>")
owner.Unconscious(200 * GET_MUTATION_POWER(src))
@@ -57,7 +57,7 @@
synchronizer_coeff = 1
power_coeff = 1
/datum/mutation/human/cough/on_life(mob/living/carbon/human/owner)
/datum/mutation/human/cough/on_life()
if(prob(5 * GET_MUTATION_SYNCHRONIZER(src)) && owner.stat == CONSCIOUS)
owner.drop_all_held_items()
owner.emote("cough")
@@ -118,7 +118,7 @@
text_gain_indication = "<span class='danger'>You twitch.</span>"
synchronizer_coeff = 1
/datum/mutation/human/tourettes/on_life(mob/living/carbon/human/owner)
/datum/mutation/human/tourettes/on_life()
if(prob(10 * GET_MUTATION_SYNCHRONIZER(src)) && owner.stat == CONSCIOUS && !owner.IsStun())
owner.Stun(200)
switch(rand(1, 3))
@@ -212,7 +212,7 @@
synchronizer_coeff = 1
power_coeff = 1
/datum/mutation/human/fire/on_life(mob/living/carbon/human/owner)
/datum/mutation/human/fire/on_life()
if(prob((1+(100-dna.stability)/10)) * GET_MUTATION_SYNCHRONIZER(src))
owner.adjust_fire_stacks(2 * GET_MUTATION_POWER(src))
owner.IgniteMob()
@@ -268,7 +268,7 @@
text_gain_indication = "<span class='danger'>You feel screams echo through your mind...</span>"
text_lose_indication = "<span class'notice'>The screaming in your mind fades.</span>"
/datum/mutation/human/paranoia/on_life(mob/living/carbon/human/owner)
/datum/mutation/human/paranoia/on_life()
if(prob(5) && owner.stat == CONSCIOUS)
owner.emote("scream")
owner.jitteriness = min(max(0, owner.jitteriness + 5), 30)
+3 -3
View File
@@ -14,13 +14,13 @@
return
owner.alpha = CHAMELEON_MUTATION_DEFAULT_TRANSPARENCY
/datum/mutation/human/chameleon/on_life(mob/living/carbon/human/owner)
/datum/mutation/human/chameleon/on_life()
owner.alpha = max(0, owner.alpha - 25)
/datum/mutation/human/chameleon/on_move(mob/living/carbon/human/owner)
/datum/mutation/human/chameleon/on_move(atom/new_loc)
owner.alpha = CHAMELEON_MUTATION_DEFAULT_TRANSPARENCY
/datum/mutation/human/chameleon/on_attack_hand(mob/living/carbon/human/owner, atom/target, proximity)
/datum/mutation/human/chameleon/on_attack_hand(atom/target, proximity)
if(proximity) //stops tk from breaking chameleon
owner.alpha = CHAMELEON_MUTATION_DEFAULT_TRANSPARENCY
return
+2 -2
View File
@@ -19,11 +19,11 @@
SEND_SIGNAL(owner, COMSIG_ADD_MOOD_EVENT, "hulk", /datum/mood_event/hulk)
RegisterSignal(owner, COMSIG_MOB_SAY, .proc/handle_speech)
/datum/mutation/human/hulk/on_attack_hand(mob/living/carbon/human/owner,atom/target, proximity)
/datum/mutation/human/hulk/on_attack_hand(atom/target, proximity)
if(proximity) //no telekinetic hulk attack
return target.attack_hulk(owner)
/datum/mutation/human/hulk/on_life(mob/living/carbon/human/owner)
/datum/mutation/human/hulk/on_life()
if(owner.health < 0)
on_losing(owner)
to_chat(owner, "<span class='danger'>You suddenly feel very weak.</span>")
+1 -1
View File
@@ -7,7 +7,7 @@
instability = 5
difficulty = 8
/datum/mutation/human/radioactive/on_life(mob/living/carbon/human/owner)
/datum/mutation/human/radioactive/on_life()
radiation_pulse(owner, 20)
/datum/mutation/human/radioactive/New(class_ = MUT_OTHER, timer, datum/mutation/human/copymut)
+1 -1
View File
@@ -13,7 +13,7 @@
if(!(type in visual_indicators))
visual_indicators[type] = list(mutable_appearance('icons/effects/genetics.dmi', "fire", -MUTATIONS_LAYER))
/datum/mutation/human/space_adaptation/get_visual_indicator(mob/living/carbon/human/owner)
/datum/mutation/human/space_adaptation/get_visual_indicator()
return visual_indicators[type][1]
/datum/mutation/human/space_adaptation/on_acquiring(mob/living/carbon/human/owner)
+1 -1
View File
@@ -7,7 +7,7 @@
quality = MINOR_NEGATIVE
text_gain_indication = "<span class='danger'>You feel nervous.</span>"
/datum/mutation/human/nervousness/on_life(mob/living/carbon/human/owner)
/datum/mutation/human/nervousness/on_life()
if(prob(10))
owner.stuttering = max(10, owner.stuttering)
+3 -3
View File
@@ -13,8 +13,8 @@
if(!(type in visual_indicators))
visual_indicators[type] = list(mutable_appearance('icons/effects/genetics.dmi', "telekinesishead", -MUTATIONS_LAYER))
/datum/mutation/human/telekinesis/get_visual_indicator(mob/living/carbon/human/owner)
/datum/mutation/human/telekinesis/get_visual_indicator()
return visual_indicators[type][1]
/datum/mutation/human/telekinesis/on_ranged_attack(mob/living/carbon/human/owner, atom/target)
target.attack_tk(owner)
/datum/mutation/human/telekinesis/on_ranged_attack(atom/target, mouseparams)
target.attack_tk(owner)