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
This commit is contained in:
d3athrow
2014-07-16 11:58:34 -05:00
committed by ZomgPonies
parent b9b6d09f23
commit 994a5bebbf
7 changed files with 133 additions and 3 deletions
+2 -1
View File
@@ -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)
+51
View File
@@ -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
+56
View File
@@ -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 = "<i>Your throat feels sore..</i>"
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)
+2
View File
@@ -269,3 +269,5 @@ Obviously, requires DNA2.
else
remoteview_target = null
reset_view(0)
+20 -1
View File
@@ -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()
+1 -1
View File
@@ -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]