diff --git a/Content.Server/Traits/TraitSystem.cs b/Content.Server/Traits/TraitSystem.cs index bd36b4ecefb..afdf01524de 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 7c0e429a691..fb8ccf54640 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 d5c993e2994..921546d466c 100644 --- a/Resources/Locale/en-US/traits/traits.ftl +++ b/Resources/Locale/en-US/traits/traits.ftl @@ -318,6 +318,10 @@ 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. + trait-name-Liar = Pathological liar trait-description-Liar = You can hardly bring yourself to tell the truth. Sometimes you lie anyway. diff --git a/Resources/Prototypes/Traits/skills.yml b/Resources/Prototypes/Traits/skills.yml index 0d6eb045ac6..fb0c6d4fc91 100644 --- a/Resources/Prototypes/Traits/skills.yml +++ b/Resources/Prototypes/Traits/skills.yml @@ -297,8 +297,13 @@ componentRemovals: - PsionicInsulation requirements: - - !type:CharacterLogicOrRequirement - requirements: - - !type:CharacterSpeciesRequirement - species: - - IPC + - !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 02a2ac168d3..cdbbf868662 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