diff --git a/Content.Server/Traits/TraitSystem.cs b/Content.Server/Traits/TraitSystem.cs index bd36b4ecef..afdf01524d 100644 --- a/Content.Server/Traits/TraitSystem.cs +++ b/Content.Server/Traits/TraitSystem.cs @@ -14,6 +14,7 @@ using Content.Shared.Psionics; using Content.Server.Language; using Content.Shared.Mood; +using Content.Server.NPC.Systems; namespace Content.Server.Traits; @@ -28,6 +29,7 @@ public sealed class TraitSystem : EntitySystem [Dependency] private readonly PsionicAbilitiesSystem _psionicAbilities = default!; [Dependency] private readonly IComponentFactory _componentFactory = default!; [Dependency] private readonly LanguageSystem _languageSystem = default!; + [Dependency] private readonly NpcFactionSystem _factionSystem = default!; public override void Initialize() { @@ -71,6 +73,8 @@ public void AddTrait(EntityUid uid, TraitPrototype traitPrototype) AddTraitLanguage(uid, traitPrototype); RemoveTraitLanguage(uid, traitPrototype); AddTraitMoodlets(uid, traitPrototype); + RemoveTraitFactions(uid, traitPrototype); + AddTraitFactions(uid, traitPrototype); } /// @@ -225,4 +229,28 @@ public void AddTraitMoodlets(EntityUid uid, TraitPrototype traitPrototype) if (_prototype.TryIndex(moodProto, out var moodlet)) RaiseLocalEvent(uid, new MoodEffectEvent(moodlet.ID)); } + + /// + /// If a trait includes any faction removals, this removes the faction from the receiving entity. + /// + public void RemoveTraitFactions(EntityUid uid, TraitPrototype traitPrototype) + { + if (traitPrototype.RemoveFactions is null) + return; + + foreach (var faction in traitPrototype.RemoveFactions) + _factionSystem.RemoveFaction(uid, faction); + } + + /// + /// If a trait includes any factions to add, this adds the factions to the receiving entity. + /// + public void AddTraitFactions(EntityUid uid, TraitPrototype traitPrototype) + { + if (traitPrototype.AddFactions is null) + return; + + foreach (var faction in traitPrototype.AddFactions) + _factionSystem.AddFaction(uid, faction); + } } diff --git a/Content.Shared/Traits/Prototypes/TraitPrototype.cs b/Content.Shared/Traits/Prototypes/TraitPrototype.cs index 7c0e429a69..fb8ccf5464 100644 --- a/Content.Shared/Traits/Prototypes/TraitPrototype.cs +++ b/Content.Shared/Traits/Prototypes/TraitPrototype.cs @@ -87,4 +87,22 @@ public sealed partial class TraitPrototype : IPrototype /// [DataField] public List>? MoodEffects { get; private set; } = default!; + + /// + /// The list of all Factions that this trait removes. + /// + /// + /// I can't actually Validate these because the proto lives in Shared. + /// + [DataField] + public List? RemoveFactions { get; private set; } = default!; + + /// + /// The list of all Factions that this trait adds. + /// + /// + /// I can't actually Validate these because the proto lives in Shared. + /// + [DataField] + public List? AddFactions { get; private set; } = default!; } diff --git a/Resources/Locale/en-US/traits/traits.ftl b/Resources/Locale/en-US/traits/traits.ftl index 4db6055e46..9409576c81 100644 --- a/Resources/Locale/en-US/traits/traits.ftl +++ b/Resources/Locale/en-US/traits/traits.ftl @@ -314,3 +314,7 @@ trait-description-Spinarette = trait-name-AddictionNicotine = Nicotine Addiction trait-description-AddictionNicotine = You have an addiction to Nicotine, and will require frequent smoke breaks to keep your mood in check. + +trait-name-AnimalFriend = Animal Friend +trait-description-AnimalFriend = + You have a way with animals. You will never be attacked by animals, unless you attack them first. diff --git a/Resources/Prototypes/Traits/skills.yml b/Resources/Prototypes/Traits/skills.yml index 0e4868f19b..e68d72ee92 100644 --- a/Resources/Prototypes/Traits/skills.yml +++ b/Resources/Prototypes/Traits/skills.yml @@ -282,3 +282,10 @@ - !type:CharacterSpeciesRequirement species: - IPC + +- type: trait + id: AnimalFriend + category: Mental + points: -4 + addFactions: + - AnimalFriend diff --git a/Resources/Prototypes/ai_factions.yml b/Resources/Prototypes/ai_factions.yml index 02a2ac168d..cdbbf86866 100644 --- a/Resources/Prototypes/ai_factions.yml +++ b/Resources/Prototypes/ai_factions.yml @@ -35,6 +35,8 @@ - type: npcFaction id: SimpleHostile + friendly: + - AnimalFriend hostile: - NanoTrasen - Syndicate @@ -86,6 +88,8 @@ - type: npcFaction id: Pibble + friendly: + - AnimalFriend hostile: - Cat - Birb @@ -99,3 +103,6 @@ - type: npcFaction id: Birb + +- type: npcFaction + id: AnimalFriend