Skip to content
Open
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
2 changes: 1 addition & 1 deletion Content.Server/Humanoid/Systems/RandomHumanoidSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public EntityUid SpawnRandomHumanoid(string prototypeId, EntityCoordinates coord
if (!_prototypeManager.TryIndex<RandomHumanoidSettingsPrototype>(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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var profile = HumanoidCharacterProfile.Random(prototype.SpeciesBlacklist, false); // MACRO
var profile = HumanoidCharacterProfile.Random(prototype.SpeciesBlacklist, false); // MACRO, added false

var speciesProto = _prototypeManager.Index<SpeciesPrototype>(profile.Species);
var humanoid = EntityManager.CreateEntityUninitialized(speciesProto.Prototype, coordinates);

Expand Down
16 changes: 16 additions & 0 deletions Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,22 @@ public sealed partial class SpeciesPrototype : IPrototype
/// </summary>
[DataField]
public int MaxAge = 120;

// MACRO start
/// <summary>
/// Whether the species is viable to roll when a humanoid's
/// species is randomized outside of character creation.
/// </summary>
[DataField]
public bool MidRoundRandomViable { get; private set; }

/// <summary>
/// When a random species is picked, verify random float is lower than this number
/// if not, don't pick the species.
/// </summary>
[DataField]
public float RandomChance { get; private set; } = 1f;
// MACRO end
}

public enum SpeciesNaming : byte
Expand Down
14 changes: 12 additions & 2 deletions Content.Shared/Preferences/HumanoidCharacterProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,24 @@ public static HumanoidCharacterProfile DefaultWithSpecies(ProtoId<SpeciesPrototy
}

// TODO: This should eventually not be a visual change only.
public static HumanoidCharacterProfile Random(HashSet<string>? ignoredSpecies = null)
public static HumanoidCharacterProfile Random(HashSet<string>? speciesBlacklist = null, bool? characterCreation = true) // MACRO visitor species: add characterCreation
{
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var random = IoCManager.Resolve<IRobustRandom>();

var species = random.Pick(prototypeManager
.EnumeratePrototypes<SpeciesPrototype>()
.Where(x => ignoredSpecies == null ? x.RoundStart : x.RoundStart && !ignoredSpecies.Contains(x.ID))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment out instead of deleting
macro start above this line, note that its for visitor species

// MACRO visitor species: replace .Where
//.Where(x => ignoredSpecies == null ? x.RoundStart : x.RoundStart && !ignoredSpecies.Contains(x.ID)) // MACRO visitor species: commented out
.Where(x =>
{
if (speciesBlacklist != null && speciesBlacklist.Contains(x.ID))
return false;
if (characterCreation == true)
return x.RoundStart;
return random.NextFloat() < x.RandomChance && x.MidRoundRandomViable;
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macro end here

// MACRO end
.ToArray()
).ID;

Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Species/arachnid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
id: Arachnid
name: species-name-arachnid
roundStart: true
midRoundRandomViable: true # MACRO
prototype: MobArachnid
defaultSkinTone: "#385878"
dollPrototype: AppearanceArachnid
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Species/diona.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
id: Diona
name: species-name-diona
roundStart: true
midRoundRandomViable: true # MACRO
prototype: MobDiona
defaultSkinTone: "#cdb369"
dollPrototype: AppearanceDiona
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Species/dwarf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
id: Dwarf
name: species-name-dwarf
roundStart: true
midRoundRandomViable: true # MACRO
prototype: MobDwarf
dollPrototype: AppearanceDwarf
skinColoration: HumanToned
1 change: 1 addition & 0 deletions Resources/Prototypes/Species/human.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
id: Human
name: species-name-human
roundStart: true
midRoundRandomViable: true # MACRO
prototype: MobHuman
dollPrototype: AppearanceHuman
skinColoration: HumanToned
1 change: 1 addition & 0 deletions Resources/Prototypes/Species/moth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
id: Moth
name: species-name-moth
roundStart: true
midRoundRandomViable: true # MACRO
prototype: MobMoth
defaultSkinTone: "#ffda93"
dollPrototype: AppearanceMoth
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Species/reptilian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
id: Reptilian
name: species-name-reptilian
roundStart: true
midRoundRandomViable: true # MACRO
prototype: MobReptilian
defaultSkinTone: "#34a223"
dollPrototype: AppearanceReptilian
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Species/slime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
id: SlimePerson
name: species-name-slime
roundStart: true
midRoundRandomViable: true # MACRO
prototype: MobSlimePerson
defaultSkinTone: "#b8b8b8"
dollPrototype: AppearanceSlimePerson
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Species/vox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
id: Vox
name: species-name-vox
roundStart: true
midRoundRandomViable: true # MACRO
prototype: MobVox
dollPrototype: AppearanceVox
skinColoration: VoxFeathers
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/_MACRO/Species/apid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: Apid
name: species-name-apid
roundStart: false
#randomViable: false
midRoundRandomViable: false
prototype: MobApid
defaultSkinTone: "#fcd719"
dollPrototype: AppearanceApid
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/_MACRO/Species/gastropoid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: Gastropoid
name: species-name-gastropoid
roundStart: false
#randomViable: false
midRoundRandomViable: false
prototype: MobGastropoid
defaultSkinTone: "#385878"
dollPrototype: AppearanceGastropoid
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/_MACRO/Species/gray.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: Gray
name: species-name-gray
roundStart: false
#randomViable: false
midRoundRandomViable: false
prototype: MobGray
dollPrototype: AppearanceGray
skinColoration: GrayToned
Expand Down
Loading