ports hyper's genetics
This commit is contained in:
+96
-40
@@ -1,58 +1,55 @@
|
||||
GLOBAL_LIST_EMPTY(mutations_list)
|
||||
|
||||
/datum/mutation
|
||||
|
||||
var/name
|
||||
|
||||
/datum/mutation/New()
|
||||
GLOB.mutations_list[name] = src
|
||||
|
||||
/datum/mutation/human
|
||||
var/dna_block
|
||||
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
|
||||
|
||||
/datum/mutation/human/proc/force_give(mob/living/carbon/human/owner)
|
||||
set_block(owner)
|
||||
. = on_acquiring(owner)
|
||||
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
|
||||
|
||||
/datum/mutation/human/proc/force_lose(mob/living/carbon/human/owner)
|
||||
set_block(owner, 0)
|
||||
. = on_losing(owner)
|
||||
//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/proc/set_se(se_string, on = 1)
|
||||
if(!se_string || length(se_string) < DNA_STRUC_ENZYMES_BLOCKS * DNA_BLOCK_SIZE)
|
||||
return
|
||||
var/before = copytext(se_string, 1, ((dna_block - 1) * DNA_BLOCK_SIZE) + 1)
|
||||
var/injection = num2hex(on ? rand(lowest_value, (256 * 16) - 1) : rand(0, lowest_value - 1), DNA_BLOCK_SIZE)
|
||||
var/after = copytext(se_string, (dna_block * DNA_BLOCK_SIZE) + 1, 0)
|
||||
return before + injection + after
|
||||
|
||||
/datum/mutation/human/proc/set_block(mob/living/carbon/owner, on = 1)
|
||||
if(owner && owner.has_dna())
|
||||
owner.dna.struc_enzymes = set_se(owner.dna.struc_enzymes, on)
|
||||
|
||||
/datum/mutation/human/proc/check_block_string(se_string)
|
||||
if(!se_string || length(se_string) < DNA_STRUC_ENZYMES_BLOCKS * DNA_BLOCK_SIZE)
|
||||
return 0
|
||||
if(hex2num(getblock(se_string, dna_block)) >= lowest_value)
|
||||
return 1
|
||||
|
||||
/datum/mutation/human/proc/check_block(mob/living/carbon/human/owner, force_powers=0)
|
||||
if(check_block_string(owner.dna.struc_enzymes))
|
||||
if(prob(get_chance)||force_powers)
|
||||
. = on_acquiring(owner)
|
||||
else
|
||||
. = on_losing(owner)
|
||||
/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/owner)
|
||||
if(!owner || !istype(owner) || owner.stat == DEAD || (src in owner.dna.mutations))
|
||||
@@ -63,7 +60,8 @@ GLOBAL_LIST_EMPTY(mutations_list)
|
||||
return TRUE
|
||||
if(limb_req && !owner.get_bodypart(limb_req))
|
||||
return TRUE
|
||||
owner.dna.mutations.Add(src)
|
||||
dna = owner.dna
|
||||
dna.mutations += src
|
||||
if(text_gain_indication)
|
||||
to_chat(owner, text_gain_indication)
|
||||
if(visual_indicators.len)
|
||||
@@ -75,6 +73,10 @@ GLOBAL_LIST_EMPTY(mutations_list)
|
||||
owner.overlays_standing[layer_used] = mut_overlay
|
||||
owner.apply_overlay(layer_used)
|
||||
|
||||
grant_spell(owner)
|
||||
if(!modified)
|
||||
addtimer(CALLBACK(src, .proc/modify, 5)) //gonna want children calling ..() to run first
|
||||
|
||||
/datum/mutation/human/proc/get_visual_indicator(mob/living/carbon/human/owner)
|
||||
return
|
||||
|
||||
@@ -102,26 +104,80 @@ GLOBAL_LIST_EMPTY(mutations_list)
|
||||
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))
|
||||
CM.force_lose(src) //shouldn't have that mutation at all
|
||||
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(src)
|
||||
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)
|
||||
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(mob/living/carbon/human/owner)
|
||||
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
|
||||
Reference in New Issue
Block a user