Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
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
15 changes: 15 additions & 0 deletions Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ public sealed partial class SpeciesPrototype : IPrototype
/// </summary>
[DataField]
public int MaxAge = 120;

// MACRO start
/// <summary>
/// Whether or not the species is available for randomization.
/// </summary>
[DataField]
public bool RandomViable { get; private set; }
Comment on lines +110 to +114
Copy link
Contributor

Choose a reason for hiding this comment

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

name of this bool is kind of vague. what does 'randomization' mean in this context?
maybe rename or include in the comment whether or not youre talking about in game or character creation?


/// <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
19 changes: 15 additions & 4 deletions Content.Shared/Preferences/HumanoidCharacterProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,31 @@ public static HumanoidCharacterProfile DefaultWithSpecies(ProtoId<SpeciesPrototy
}

// TODO: This should eventually not be a visual change only.
public static HumanoidCharacterProfile Random(HashSet<string>? ignoredSpecies = null)
// MACRO start. this function is fairly different from upstream now.
// But upstreaming this would take so long that the species will be fully merged by then
// Therefore: bear with my changes
public static HumanoidCharacterProfile Random(HashSet<string>? speciesBlacklist = null, bool? characterCreation = true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public static HumanoidCharacterProfile Random(HashSet<string>? speciesBlacklist = null, bool? characterCreation = true)
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
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

.Where(x =>
{
if (speciesBlacklist != null && speciesBlacklist.Contains(x.ID))
return false;
if (characterCreation == true)
return x.RoundStart;
return random.NextFloat() < x.RandomChance && x.RandomViable;
})
Copy link
Contributor

Choose a reason for hiding this comment

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

macro end here

.ToArray()
).ID;
)
.ID;
Comment on lines +234 to +235
Copy link
Contributor

Choose a reason for hiding this comment

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

revert


return RandomWithSpecies(species);
}

// MACRO end
Copy link
Contributor

Choose a reason for hiding this comment

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

delete

public static HumanoidCharacterProfile RandomWithSpecies(string? species = null)
{
species ??= HumanoidCharacterProfile.DefaultSpecies;
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
randomViable: 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
randomViable: 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
randomViable: 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
randomViable: 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
randomViable: 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
randomViable: 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
randomViable: true # MACRO
prototype: MobSlimePerson
defaultSkinTone: "#b8b8b8"
dollPrototype: AppearanceSlimePerson
Expand Down
3 changes: 2 additions & 1 deletion Resources/Prototypes/Species/vox.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
- type: species
id: Vox
name: species-name-vox
roundStart: true
roundStart: true # MACRO
randomViable: true
prototype: MobVox
dollPrototype: AppearanceVox
skinColoration: VoxFeathers
Expand Down