Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Unhardcode dna vault/dna upg #6250

Draft
wants to merge 27 commits into
base: master220
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion code/_globalvars/genetics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,3 @@ GLOBAL_VAR_INIT(fakeblock1, 0)
GLOBAL_VAR_INIT(fakeblock2, 0)
GLOBAL_VAR_INIT(fakeblock3, 0)
GLOBAL_VAR_INIT(fakeblock4, 0)

6 changes: 4 additions & 2 deletions code/game/dna/dna2.dm
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,14 @@ GLOBAL_LIST_EMPTY(bad_blocks)
var/value = GetSEValue(block)
return round(1 + (value / 4096) * maxvalue)

// Is the block "on" (1) or "off" (0)? (Un-assigned genes are always off.)
/// Is the block "on" (1) or "off" (0)? (Un-assigned genes are always off.)
/datum/dna/proc/GetSEState(block)
if(block <= 0)
if(!block)
return FALSE

var/list/BOUNDS = GetDNABounds(block)
var/value = GetSEValue(block)

return (value >= BOUNDS[DNA_ON_LOWERBOUND])

// Set a block "on" or "off".
Expand Down
18 changes: 14 additions & 4 deletions code/game/dna/dna2_domutcheck.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
return FALSE

// Gene is in bounds but not active currently
if(gene_in_bounds && !gene_is_active)
if((gene_in_bounds && gene.block) && !gene_is_active)
// If our gene should be activated, we need to check for conditions
if(!gene.can_activate(src, flags))
return FALSE
Expand All @@ -75,9 +75,10 @@
return TRUE

// Same with deactivation stuff
if(!gene_in_bounds && gene_is_active)
if((!gene_in_bounds && gene.block) && gene_is_active)
if(!gene.can_deactivate(src, flags))
return FALSE

INVOKE_ASYNC(gene, TYPE_PROC_REF(/datum/dna/gene, deactivate), src, flags)
return TRUE

Expand All @@ -102,15 +103,24 @@
return


/mob/living/carbon/human/force_gene_block(block, activate = FALSE, update_default_status = FALSE, ignore_species_default = FALSE)
/mob/living/carbon/human/force_gene_block(
block,
activate = FALSE,
update_default_status = FALSE,
ignore_species_default = FALSE
)
var/force_flags = MUTCHK_FORCED

if(ignore_species_default)
force_flags |= MUTCHK_IGNORE_DEFAULT

dna.SetSEState(block, activate)

. = check_gene_block(block, force_flags)

if(. && update_default_status)
if(activate)
LAZYOR(dna.default_blocks, block)

else
LAZYREMOVE(dna.default_blocks, block)

18 changes: 13 additions & 5 deletions code/game/dna/genes/gene.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* Is the gene active in this mob's DNA?
*/
/datum/dna/gene/proc/is_active(mob/living/mutant)
return LAZYIN(mutant.active_genes, type)
return LAZYIN(mutant.active_genes, src)


/// Return `TRUE` if we can activate.
Expand All @@ -57,10 +57,14 @@
/// Called when the gene activates. Do your magic here.
/datum/dna/gene/proc/activate(mob/living/mutant, flags)
SHOULD_CALL_PARENT(TRUE)
LAZYOR(mutant.active_genes, type)

LAZYOR(mutant.active_genes, src)

mutant.gene_stability -= instability
if(length(traits_to_add))

if(LAZYLEN(traits_to_add))
mutant.add_traits(traits_to_add, DNA_TRAIT)

mutant.update_mutations()


Expand All @@ -70,10 +74,14 @@
*/
/datum/dna/gene/proc/deactivate(mob/living/mutant, flags)
SHOULD_CALL_PARENT(TRUE)
LAZYREMOVE(mutant.active_genes, type)

LAZYREMOVE(mutant.active_genes, src)

mutant.gene_stability += instability
if(length(traits_to_add))

if(LAZYLEN(traits_to_add))
mutant.remove_traits(traits_to_add, DNA_TRAIT)

mutant.update_mutations()


Expand Down
151 changes: 151 additions & 0 deletions code/game/dna/genes/vault.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/datum/dna/gene/basic/vault

/datum/dna/gene/basic/vault/can_activate(mob/living/carbon/human/human, flags)
return istype(human)

/datum/dna/gene/basic/vault/toxin
name = "Toxin Adaptation"

var/cached_tox_breath_dam_min
var/cached_tox_breath_dam_max

traits_to_add = list(TRAIT_VIRUSIMMUNE)

activation_messages = list(
span_notice("Ваше тело стало невоспримчивым к токсинам в воздухе.")
)

/datum/dna/gene/basic/vault/toxin/activate(mob/living/carbon/human/human, flags)
. = ..()

var/obj/item/organ/internal/lungs/lungs = human.get_int_organ(/obj/item/organ/internal/lungs)

if(lungs)
cached_tox_breath_dam_min = lungs.tox_breath_dam_min
cached_tox_breath_dam_max = lungs.tox_breath_dam_max

lungs.tox_breath_dam_min = 0
lungs.tox_breath_dam_max = 0

/datum/dna/gene/basic/vault/toxin/deactivate(mob/living/carbon/human/human, flags)
. = ..()

var/obj/item/organ/internal/lungs/lungs = human.get_int_organ(/obj/item/organ/internal/lungs)

if(lungs)
lungs.tox_breath_dam_min = cached_tox_breath_dam_min || initial(lungs.tox_breath_dam_min)
lungs.tox_breath_dam_max = cached_tox_breath_dam_max || initial(lungs.tox_breath_dam_max)

/datum/dna/gene/basic/vault/nobreath
name = "Lung Enhancement"

traits_to_add = list(TRAIT_NO_BREATH)

activation_messages = list(
span_notice("Вы чувствуете, как нужда в дыхании пропадает.")
)

/datum/dna/gene/basic/vault/fireproof
name = "Thermal Regulation"

traits_to_add = list(TRAIT_RESIST_HEAT)

activation_messages = list(
span_notice("Вы чувствуете, как ваше тело стало более огнеупорным.")
)

/datum/dna/gene/basic/vault/fireproof/activate(mob/living/carbon/human/human, flags)
. = ..()

human.physiology.burn_mod *= 0.5

/datum/dna/gene/basic/vault/fireproof/deactivate(mob/living/carbon/human/human, flags)
. = ..()

human.physiology.burn_mod /= 0.5

/datum/dna/gene/basic/vault/stuntime
name = "Neural Repathing"

activation_messages = list(
span_notice("Ничто не может долго сдерживать вас.")
)

/datum/dna/gene/basic/vault/stuntime/activate(mob/living/carbon/human/human, flags)
. = ..()

human.physiology.stun_mod *= 0.5
human.physiology.stamina_mod *= 0.5
human.stam_regen_start_modifier *= 0.5

/datum/dna/gene/basic/vault/stuntime/deactivate(mob/living/carbon/human/human, flags)
. = ..()

human.physiology.stun_mod /= 0.5
human.physiology.stamina_mod /= 0.5
human.stam_regen_start_modifier /= 0.5

/datum/dna/gene/basic/vault/armour
name = "Hardened Skin"

traits_to_add = list(TRAIT_PIERCEIMMUNE)

activation_messages = list(
span_notice("Вы чувствуете себя крепче.")
)

/datum/dna/gene/basic/vault/armour/activate(mob/living/carbon/human/human, flags)
. = ..()

human.physiology.brute_mod *= 0.7
human.physiology.burn_mod *= 0.7
human.physiology.tox_mod *= 0.7
human.physiology.oxy_mod *= 0.7
human.physiology.clone_mod *= 0.7
human.physiology.brain_mod *= 0.7
human.physiology.stamina_mod *= 0.7

/datum/dna/gene/basic/vault/armour/deactivate(mob/living/carbon/human/human, flags)
. = ..()

human.physiology.brute_mod /= 0.7
human.physiology.burn_mod /= 0.7
human.physiology.tox_mod /= 0.7
human.physiology.oxy_mod /= 0.7
human.physiology.clone_mod /= 0.7
human.physiology.brain_mod /= 0.7
human.physiology.stamina_mod /= 0.7

/datum/dna/gene/basic/vault/speedlegs
name = "Leg Muscle Stimulus"

activation_messages = list(
span_notice("Вы чувствуете себя быстрее и ловче.")
)

/datum/dna/gene/basic/vault/speedlegs/activate(mob/living/carbon/human/human, flags)
. = ..()

human.add_movespeed_modifier(/datum/movespeed_modifier/dna_vault_speedup)

/datum/dna/gene/basic/vault/speedlegs/deactivate(mob/living/carbon/human/human, flags)
. = ..()

human.remove_movespeed_modifier(/datum/movespeed_modifier/dna_vault_speedup)

/datum/dna/gene/basic/vault/quickarms
name = "Arm Muscle Stimulus"

activation_messages = list(
span_notice("Ваши руки двигаются также быстро, как и молния.")
)

/datum/dna/gene/basic/vault/quickarms/activate(mob/living/carbon/human/human, flags)
. = ..()

human.next_move_modifier *= 0.5

/datum/dna/gene/basic/vault/quickarms/deactivate(mob/living/carbon/human/human, flags)
. = ..()

human.next_move_modifier /= 0.5
10 changes: 8 additions & 2 deletions code/game/gamemodes/setupgame.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,29 @@
if(!length(blocksLeft))
warning("[name]: No more blocks left to assign!")
return 0

var/assigned = pick(blocksLeft)
blocksLeft.Remove(assigned)

if(good)
GLOB.good_blocks += assigned

else
GLOB.bad_blocks += assigned

GLOB.assigned_blocks[assigned] = name
GLOB.dna_activity_bounds[assigned] = activity_bounds

return assigned


/proc/setupgenetics()

if(prob(50))
GLOB.blockadd = rand(-300,300)
GLOB.blockadd = rand(-300, 300)

if(prob(75))
GLOB.diffmut = rand(0,20)
GLOB.diffmut = rand(0, 20)

// SE blocks to assign.
var/list/numsToAssign= list()
Expand Down
Loading
Loading