adds a unique species id unit test + cleans up some golem mischief (#66050)

This commit is contained in:
capsaicin
2022-04-11 00:33:24 -05:00
committed by GitHub
parent 0e805709e0
commit abc2109a5d
6 changed files with 35 additions and 24 deletions
@@ -1024,9 +1024,6 @@
/mob/living/carbon/human/species/golem
race = /datum/species/golem
/mob/living/carbon/human/species/golem/random
race = /datum/species/golem/random
/mob/living/carbon/human/species/golem/adamantine
race = /datum/species/golem/adamantine
@@ -83,24 +83,6 @@
return to_add
/datum/species/golem/random
name = "Random Golem"
changesource_flags = MIRROR_BADMIN | WABBAJACK | MIRROR_PRIDE | MIRROR_MAGIC | RACE_SWAP | ERT_SPAWN
var/static/list/random_golem_types
/datum/species/golem/random/on_species_gain(mob/living/carbon/C, datum/species/old_species)
..()
if(!random_golem_types)
random_golem_types = subtypesof(/datum/species/golem) - type
for(var/V in random_golem_types)
var/datum/species/golem/G = V
if(!initial(G.random_eligible))
random_golem_types -= G
var/datum/species/golem/golem_type = pick(random_golem_types)
var/mob/living/carbon/human/H = C
H.set_species(golem_type)
to_chat(H, "[initial(golem_type.info_text)]")
/datum/species/golem/adamantine
name = "Adamantine Golem"
id = SPECIES_GOLEM_ADAMANTINE
@@ -653,10 +653,20 @@
name = "Golem Mutation Toxin"
description = "A crystal toxin."
color = "#5EFF3B" //RGB: 94, 255, 59
race = /datum/species/golem/random
race = /datum/species/golem
taste_description = "rocks"
chemical_flags = REAGENT_CAN_BE_SYNTHESIZED|REAGENT_NO_RANDOM_RECIPE
/datum/reagent/mutationtoxin/golem/on_mob_metabolize()
var/static/list/random_golem_types
random_golem_types = subtypesof(/datum/species/golem) - type
for(var/i in random_golem_types)
var/datum/species/golem/golem = i
if(!initial(golem.random_eligible))
random_golem_types -= golem
race = pick(random_golem_types)
..()
/datum/reagent/mutationtoxin/abductor
name = "Abductor Mutation Toxin"
description = "An alien toxin."
@@ -295,13 +295,20 @@ Chilling extracts:
/obj/item/slimecross/chilling/black
colour = "black"
effect_desc = "Transforsms the user into a random type of golem."
effect_desc = "Transforms the user into a random type of golem."
/obj/item/slimecross/chilling/black/do_effect(mob/user)
if(ishuman(user))
user.visible_message(span_notice("[src] crystallizes along [user]'s skin, turning into metallic scales!"))
var/mob/living/carbon/human/H = user
H.set_species(/datum/species/golem/random)
var/static/list/random_golem_types
random_golem_types = subtypesof(/datum/species/golem) - type
for(var/datum/species/golem/golem as anything in random_golem_types)
if(!initial(golem.random_eligible))
random_golem_types -= golem
H.set_species(pick(random_golem_types))
..()
/obj/item/slimecross/chilling/lightpink
+1
View File
@@ -108,6 +108,7 @@
#include "spawn_humans.dm"
#include "spawn_mobs.dm"
#include "species_config_sanity.dm"
#include "species_unique_id.dm"
#include "species_whitelists.dm"
#include "stomach.dm"
#include "strippable.dm"
@@ -0,0 +1,14 @@
/**
* Every species should use a species ID unique to it and it alone. This test runs through every subtype of /datum/species, and checks for a species ID.
* Every ID is written to a list, gathered_species_ids, and if a previously written ID is written again, this test will fail.
*/
/datum/unit_test/species_unique_id
/datum/unit_test/species_unique_id/Run()
var/list/gathered_species_ids = list()
for(var/datum/species/species as anything in subtypesof(/datum/species))
var/species_id = initial(species.id)
if(gathered_species_ids[species_id])
Fail("Duplicate species ID! [species_id] is not unique to a single species.")
else
gathered_species_ids[species_id] = TRUE