From 994a5bebbf1a00d25f5e98fb4d0180270b62eee7 Mon Sep 17 00:00:00 2001 From: d3athrow Date: Wed, 16 Jul 2014 11:58:34 -0500 Subject: [PATCH] Fix admins having to toggle genes several fucking times to get them to turn on sometimes. Fix adminbus toggling genes on to cause all other genes to manifest - added genemutcheck proc and domutation proc to handle the changes. Added a global list of gene datums that match the order of the randomized blocks in genetics to allow for easy lookup based on blocks and allows single gene checking to work. Conflicts: code/game/gamemodes/setupgame.dm code/modules/admin/verbs/debug.dm --- baystation12.dme | 1 + code/game/dna/dna2.dm | 3 +- code/game/dna/dna2_domutcheck.dm | 51 +++++++++++++++++++++++ code/game/dna/genes/vg_disabilities.dm | 56 ++++++++++++++++++++++++++ code/game/dna/genes/vg_powers.dm | 2 + code/game/gamemodes/setupgame.dm | 21 +++++++++- code/modules/admin/verbs/debug.dm | 2 +- 7 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 code/game/dna/genes/vg_disabilities.dm diff --git a/baystation12.dme b/baystation12.dme index 89861d96833..c0e362f5076 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -183,6 +183,7 @@ #include "code\game\dna\genes\goon_powers.dm" #include "code\game\dna\genes\monkey.dm" #include "code\game\dna\genes\powers.dm" +#include "code\game\dna\genes\vg_disabilities.dm" #include "code\game\dna\genes\vg_powers.dm" #include "code\game\gamemodes\events.dm" #include "code\game\gamemodes\factions.dm" diff --git a/code/game/dna/dna2.dm b/code/game/dna/dna2.dm index 84dc14644b3..c51f265e78c 100644 --- a/code/game/dna/dna2.dm +++ b/code/game/dna/dna2.dm @@ -42,6 +42,7 @@ // and to tell our new DNA datum which values to set in order to turn something // on or off. var/global/list/dna_activity_bounds[DNA_SE_LENGTH] +var/global/list/assigned_gene_blocks[DNA_SE_LENGTH] // Used to determine what each block means (admin hax and species stuff on /vg/, mostly) var/global/list/assigned_blocks[DNA_SE_LENGTH] @@ -277,7 +278,7 @@ var/global/list/bad_blocks[0] if (block<=0) return 0 var/list/BOUNDS=GetDNABounds(block) var/value=GetSEValue(block) - return (value > BOUNDS[DNA_ON_LOWERBOUND]) + return (value >= BOUNDS[DNA_ON_LOWERBOUND]) // Set a block "on" or "off". /datum/dna/proc/SetSEState(var/block,var/on,var/defer=0) diff --git a/code/game/dna/dna2_domutcheck.dm b/code/game/dna/dna2_domutcheck.dm index 885b106a35d..c90e2a9b400 100644 --- a/code/game/dna/dna2_domutcheck.dm +++ b/code/game/dna/dna2_domutcheck.dm @@ -11,6 +11,10 @@ if(!gene.block) continue + domutation(gene, M, connected, flags) + // To prevent needless copy pasting of code i put this commented out section + // into domutation so domutcheck and genemutcheck can both use it. + /* // Sanity checks, don't skip. if(!gene.can_activate(M,flags)) //testing("[M] - Failed to activate [gene.name] (can_activate fail).") @@ -41,3 +45,50 @@ if(M) M.active_genes -= gene.type M.update_icon = 1 + */ + +// Use this to force a mut check on a single gene! +/proc/genemutcheck(var/mob/living/M, var/block, var/connected=null, var/flags=0) + if(!M) + return + if(block < 0) + return + + var/datum/dna/gene/gene = assigned_gene_blocks[block] + domutation(gene, M, connected, flags) + + +/proc/domutation(var/datum/dna/gene/gene, var/mob/living/M, var/connected=null, var/flags=0) + if(!gene || !istype(gene)) + return 0 + + // Sanity checks, don't skip. + if(!gene.can_activate(M,flags)) + //testing("[M] - Failed to activate [gene.name] (can_activate fail).") + return 0 + + // Current state + var/gene_active = (gene.flags & GENE_ALWAYS_ACTIVATE) + if(!gene_active) + gene_active = M.dna.GetSEState(gene.block) + + // Prior state + var/gene_prior_status = (gene.type in M.active_genes) + var/changed = gene_active != gene_prior_status || (gene.flags & GENE_ALWAYS_ACTIVATE) + + // If gene state has changed: + if(changed) + // Gene active (or ALWAYS ACTIVATE) + if(gene_active || (gene.flags & GENE_ALWAYS_ACTIVATE)) + testing("[gene.name] activated!") + gene.activate(M,connected,flags) + if(M) + M.active_genes |= gene.type + M.update_icon = 1 + // If Gene is NOT active: + else + testing("[gene.name] deactivated!") + gene.deactivate(M,connected,flags) + if(M) + M.active_genes -= gene.type + M.update_icon = 1 diff --git a/code/game/dna/genes/vg_disabilities.dm b/code/game/dna/genes/vg_disabilities.dm new file mode 100644 index 00000000000..71c9e7610eb --- /dev/null +++ b/code/game/dna/genes/vg_disabilities.dm @@ -0,0 +1,56 @@ + +/datum/dna/gene/disability/speech/loud + name = "Loud" + desc = "Forces the speaking centre of the subjects brain to yell every sentence." + activation_message = "YOU FEEL LIKE YELLING!" + deactivation_message = "You feel like being quiet.." + + New() + ..() + block=LOUDBLOCK + + + + OnSay(var/mob/M, var/message) + message = replacetext(message,".","!") + message = replacetext(message,"?","?!") + message = replacetext(message,"!","!!") + return uppertext(message) + + +/datum/dna/gene/disability/speech/whisper + name = "Quiet" + desc = "Damages the subjects vocal cords" + activation_message = "Your throat feels sore.." + deactivation_message = "You feel fine again." + + New() + ..() + block=WHISPERBLOCK + + can_activate(var/mob/M,var/flags) + // No loud whispering. + if(M_LOUD in M.mutations) + return 0 + return ..(M,flags) + + OnSay(var/mob/M, var/message) + M.whisper(message) + + +/datum/dna/gene/disability/dizzy + name = "Dizzy" + desc = "Causes the cerebellum to shut down in some places." + activation_message = "You feel very dizzy..." + deactivation_message = "You regain your balance." + flags = GENE_UNNATURAL + + New() + ..() + block=DIZZYBLOCK + + + OnMobLife(var/mob/living/carbon/human/M) + if(!istype(M)) return + if(M_DIZZY in M.mutations) + M.make_dizzy(300) diff --git a/code/game/dna/genes/vg_powers.dm b/code/game/dna/genes/vg_powers.dm index f653110f9b6..4719e37b01c 100644 --- a/code/game/dna/genes/vg_powers.dm +++ b/code/game/dna/genes/vg_powers.dm @@ -269,3 +269,5 @@ Obviously, requires DNA2. else remoteview_target = null reset_view(0) + + diff --git a/code/game/gamemodes/setupgame.dm b/code/game/gamemodes/setupgame.dm index 623413f2ca8..53d04711096 100644 --- a/code/game/gamemodes/setupgame.dm +++ b/code/game/gamemodes/setupgame.dm @@ -92,6 +92,16 @@ SUPERFARTBLOCK = getAssignedBlock("SUPERFART", numsToAssign, DNA_HARDER_BOUNDS, good=1) POLYMORPHBLOCK = getAssignedBlock("POLYMORPH", numsToAssign, DNA_HARDER_BOUNDS, good=1) + // + // /vg/ Blocks + ///////////////////////////////////////////// + + // Disabilities + LOUDBLOCK = getAssignedBlock("LOUD", numsToAssign) + WHISPERBLOCK = getAssignedBlock("WHISPER", numsToAssign) + DIZZYBLOCK = getAssignedBlock("DIZZY", numsToAssign) + + // // Static Blocks /////////////////////////////////////////////. @@ -114,7 +124,16 @@ blocks_assigned[G.block]=assignedToBlock //testing("DNA2: Gene [G.name] assigned to block [G.block].") -// testing("DNA2: [numsToAssign.len] blocks are unused: [english_list(numsToAssign)]") + // I WILL HAVE A LIST OF GENES THAT MATCHES THE RANDOMIZED BLOCKS GODDAMNIT! + for(var/block=1;block<=DNA_SE_LENGTH;block++) + var/name = assigned_blocks[block] + for(var/datum/dna/gene/gene in dna_genes) + if(gene.name == name || gene.block == block) + if(gene.block in assigned_gene_blocks) + warning("DNA2: Gene [gene.name] trying to add to already assigned gene block list (used by [english_list(assigned_gene_blocks[block])])") + assigned_gene_blocks[block] = gene + + //testing("DNA2: [numsToAssign.len] blocks are unused: [english_list(numsToAssign)]") // Run AFTER genetics setup and AFTER species setup. /proc/setup_species() diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 21117262f64..b555f7041a4 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -1079,7 +1079,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that return if(istype(M, /mob/living/carbon)) M.dna.SetSEState(block,!M.dna.GetSEState(block)) - domutcheck(M,null) + genemutcheck(M,block,null,MUTCHK_FORCED) M.update_mutations() var/state="[M.dna.GetSEState(block)?"on":"off"]" var/blockname=assigned_blocks[block]