Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trait Modify Factions #955

Merged
merged 4 commits into from
Oct 27, 2024
Merged
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
28 changes: 28 additions & 0 deletions Content.Server/Traits/TraitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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()
{
Expand Down Expand Up @@ -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);
}

/// <summary>
Expand Down Expand Up @@ -225,4 +229,28 @@ public void AddTraitMoodlets(EntityUid uid, TraitPrototype traitPrototype)
if (_prototype.TryIndex(moodProto, out var moodlet))
RaiseLocalEvent(uid, new MoodEffectEvent(moodlet.ID));
}

/// <summary>
/// If a trait includes any faction removals, this removes the faction from the receiving entity.
/// </summary>
public void RemoveTraitFactions(EntityUid uid, TraitPrototype traitPrototype)
{
if (traitPrototype.RemoveFactions is null)
return;

VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
foreach (var faction in traitPrototype.RemoveFactions)
_factionSystem.RemoveFaction(uid, faction);
}

/// <summary>
/// If a trait includes any factions to add, this adds the factions to the receiving entity.
/// </summary>
public void AddTraitFactions(EntityUid uid, TraitPrototype traitPrototype)
{
if (traitPrototype.AddFactions is null)
return;

VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
foreach (var faction in traitPrototype.AddFactions)
_factionSystem.AddFaction(uid, faction);
}
}
18 changes: 18 additions & 0 deletions Content.Shared/Traits/Prototypes/TraitPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,22 @@ public sealed partial class TraitPrototype : IPrototype
/// </summary>
[DataField]
public List<ProtoId<MoodEffectPrototype>>? MoodEffects { get; private set; } = default!;

/// <summary>
/// The list of all Factions that this trait removes.
/// </summary>
/// <remarks>
/// I can't actually Validate these because the proto lives in Shared.
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
/// </remarks>
[DataField]
public List<string>? RemoveFactions { get; private set; } = default!;
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// The list of all Factions that this trait adds.
/// </summary>
/// <remarks>
/// I can't actually Validate these because the proto lives in Shared.
/// </remarks>
[DataField]
public List<string>? AddFactions { get; private set; } = default!;
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
}
4 changes: 4 additions & 0 deletions Resources/Locale/en-US/traits/traits.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
15 changes: 10 additions & 5 deletions Resources/Prototypes/Traits/skills.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions Resources/Prototypes/ai_factions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

- type: npcFaction
id: SimpleHostile
friendly:
- AnimalFriend
hostile:
- NanoTrasen
- Syndicate
Expand Down Expand Up @@ -86,6 +88,8 @@

- type: npcFaction
id: Pibble
friendly:
- AnimalFriend
hostile:
- Cat
- Birb
Expand All @@ -99,3 +103,6 @@

- type: npcFaction
id: Birb

- type: npcFaction
id: AnimalFriend
Loading