diff --git a/Content.Server/Humanoid/Systems/RandomHumanoidSystem.cs b/Content.Server/Humanoid/Systems/RandomHumanoidSystem.cs index 4ae69d2fd7c..c9cfbdd43f0 100644 --- a/Content.Server/Humanoid/Systems/RandomHumanoidSystem.cs +++ b/Content.Server/Humanoid/Systems/RandomHumanoidSystem.cs @@ -40,7 +40,7 @@ public EntityUid SpawnRandomHumanoid(string prototypeId, EntityCoordinates coord if (!_prototypeManager.TryIndex(prototypeId, out var prototype)) throw new ArgumentException("Could not get random humanoid settings"); - var profile = HumanoidCharacterProfile.Random(prototype.SpeciesBlacklist); + var profile = HumanoidCharacterProfile.Random(prototype.SpeciesBlacklist, false); // MACRO var speciesProto = _prototypeManager.Index(profile.Species); var humanoid = EntityManager.CreateEntityUninitialized(speciesProto.Prototype, coordinates); diff --git a/Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs b/Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs index 03cabf19d09..8803d019edc 100644 --- a/Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs +++ b/Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs @@ -105,6 +105,21 @@ public sealed partial class SpeciesPrototype : IPrototype /// [DataField] public int MaxAge = 120; + + // MACRO start + /// + /// Whether or not the species is available for randomization. + /// + [DataField] + public bool RandomViable { get; private set; } + + /// + /// When a random species is picked, verify random float is lower than this number + /// if not, don't pick the species + /// + [DataField] + public float RandomChance { get; private set; } = 1f; + // MACRO end } public enum SpeciesNaming : byte diff --git a/Content.Shared/Preferences/HumanoidCharacterProfile.cs b/Content.Shared/Preferences/HumanoidCharacterProfile.cs index 7dfd21e7182..428c760584f 100644 --- a/Content.Shared/Preferences/HumanoidCharacterProfile.cs +++ b/Content.Shared/Preferences/HumanoidCharacterProfile.cs @@ -214,19 +214,29 @@ public static HumanoidCharacterProfile DefaultWithSpecies(ProtoId? ignoredSpecies = null) + // MACRO start, extensive changes. + public static HumanoidCharacterProfile Random(HashSet? speciesBlacklist = null, bool? characterCreation = true) { var prototypeManager = IoCManager.Resolve(); var random = IoCManager.Resolve(); var species = random.Pick(prototypeManager .EnumeratePrototypes() - .Where(x => ignoredSpecies == null ? x.RoundStart : x.RoundStart && !ignoredSpecies.Contains(x.ID)) + .Where(x => + { + if (speciesBlacklist != null && speciesBlacklist.Contains(x.ID)) + return false; + if (characterCreation == true) + return x.RoundStart; + return random.NextFloat() < x.RandomChance && x.RandomViable; + }) .ToArray() - ).ID; + ) + .ID; return RandomWithSpecies(species); } + // MACRO end public static HumanoidCharacterProfile RandomWithSpecies(string? species = null) { diff --git a/Resources/Prototypes/Species/arachnid.yml b/Resources/Prototypes/Species/arachnid.yml index 10d838d01df..8bce0e5570f 100644 --- a/Resources/Prototypes/Species/arachnid.yml +++ b/Resources/Prototypes/Species/arachnid.yml @@ -2,6 +2,7 @@ id: Arachnid name: species-name-arachnid roundStart: true + randomViable: true # MACRO prototype: MobArachnid defaultSkinTone: "#385878" dollPrototype: AppearanceArachnid diff --git a/Resources/Prototypes/Species/diona.yml b/Resources/Prototypes/Species/diona.yml index 880cdfdf84e..311e13a9c4e 100644 --- a/Resources/Prototypes/Species/diona.yml +++ b/Resources/Prototypes/Species/diona.yml @@ -2,6 +2,7 @@ id: Diona name: species-name-diona roundStart: true + randomViable: true # MACRO prototype: MobDiona defaultSkinTone: "#cdb369" dollPrototype: AppearanceDiona diff --git a/Resources/Prototypes/Species/dwarf.yml b/Resources/Prototypes/Species/dwarf.yml index 0c2fbaf8b63..35f6bcb7950 100644 --- a/Resources/Prototypes/Species/dwarf.yml +++ b/Resources/Prototypes/Species/dwarf.yml @@ -2,6 +2,7 @@ id: Dwarf name: species-name-dwarf roundStart: true + randomViable: true # MACRO prototype: MobDwarf dollPrototype: AppearanceDwarf skinColoration: HumanToned diff --git a/Resources/Prototypes/Species/human.yml b/Resources/Prototypes/Species/human.yml index 24c18c00dea..38112d6f3bb 100644 --- a/Resources/Prototypes/Species/human.yml +++ b/Resources/Prototypes/Species/human.yml @@ -2,6 +2,7 @@ id: Human name: species-name-human roundStart: true + randomViable: true # MACRO prototype: MobHuman dollPrototype: AppearanceHuman skinColoration: HumanToned diff --git a/Resources/Prototypes/Species/moth.yml b/Resources/Prototypes/Species/moth.yml index 0e6fcd244a0..72e7135292d 100644 --- a/Resources/Prototypes/Species/moth.yml +++ b/Resources/Prototypes/Species/moth.yml @@ -2,6 +2,7 @@ id: Moth name: species-name-moth roundStart: true + randomViable: true # MACRO prototype: MobMoth defaultSkinTone: "#ffda93" dollPrototype: AppearanceMoth diff --git a/Resources/Prototypes/Species/reptilian.yml b/Resources/Prototypes/Species/reptilian.yml index d8491a6aec9..81bc9cb0161 100644 --- a/Resources/Prototypes/Species/reptilian.yml +++ b/Resources/Prototypes/Species/reptilian.yml @@ -2,6 +2,7 @@ id: Reptilian name: species-name-reptilian roundStart: true + randomViable: true # MACRO prototype: MobReptilian defaultSkinTone: "#34a223" dollPrototype: AppearanceReptilian diff --git a/Resources/Prototypes/Species/slime.yml b/Resources/Prototypes/Species/slime.yml index 5c3624731eb..ce814fcd2d6 100644 --- a/Resources/Prototypes/Species/slime.yml +++ b/Resources/Prototypes/Species/slime.yml @@ -2,6 +2,7 @@ id: SlimePerson name: species-name-slime roundStart: true + randomViable: true # MACRO prototype: MobSlimePerson defaultSkinTone: "#b8b8b8" dollPrototype: AppearanceSlimePerson diff --git a/Resources/Prototypes/Species/vox.yml b/Resources/Prototypes/Species/vox.yml index 3a543caca15..91d5467ca57 100644 --- a/Resources/Prototypes/Species/vox.yml +++ b/Resources/Prototypes/Species/vox.yml @@ -2,6 +2,7 @@ id: Vox name: species-name-vox roundStart: true + randomViable: true # MACRO prototype: MobVox dollPrototype: AppearanceVox skinColoration: VoxFeathers