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

[Feature] [Balance] Mood Traits & Things #961

Merged
merged 8 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
20 changes: 19 additions & 1 deletion Content.Server/Backmen/Mood/MoodComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public sealed partial class MoodComponent : Component
/// The lowest point that low morale can multiply our movement speed by. Lowering speed follows a linear curve, rather than geometric.
/// </summary>
[DataField]
public float MinimumSpeedModifier = 0.75f;
public float MinimumSpeedModifier = 0.90f;

/// <summary>
/// The maximum amount that high morale can multiply our movement speed by. This follows a significantly slower geometric sequence.
Expand All @@ -48,6 +48,24 @@ public sealed partial class MoodComponent : Component
[DataField]
public float DecreaseCritThreshold = 0.9f;

/// <summary>
/// Multiplier for positive mood effects.
/// </summary>
[DataField]
public float GoodMoodMultiplier = 1.0f;

/// <summary>
/// Multiplier for negative mood effects.
/// </summary>
[DataField]
public float BadMoodMultiplier = 1.0f;

[DataField]
public MoodThreshold BuffsMoodThreshold = MoodThreshold.Good;

[DataField]
public MoodThreshold ConsMoodThreshold = MoodThreshold.Bad;

[ViewVariables(VVAccess.ReadOnly)]
public FixedPoint2 CritThresholdBeforeModify;

Expand Down
37 changes: 24 additions & 13 deletions Content.Server/Backmen/Mood/MoodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,12 @@ private void OnRefreshMoveSpeed(EntityUid uid, MoodComponent component, RefreshM

private void OnTraitStartup(EntityUid uid, MoodModifyTraitComponent component, ComponentStartup args)
{
if (component.MoodId != null)
RaiseLocalEvent(uid, new MoodEffectEvent($"{component.MoodId}"));
if (!TryComp<MoodComponent>(uid, out var mood))
return;

mood.GoodMoodMultiplier = component.GoodMoodMultiplier;
mood.BadMoodMultiplier = component.BadMoodMultiplier;
RaiseLocalEvent(uid, new MoodEffectEvent($"{component.MoodId}"));
}

private void OnMoodEffect(EntityUid uid, MoodComponent component, MoodEffectEvent args)
Expand Down Expand Up @@ -308,12 +312,18 @@ private void RefreshMood(EntityUid uid, MoodComponent component)
if (!_prototypeManager.TryIndex<MoodEffectPrototype>(protoId, out var prototype))
continue;

amount += prototype.MoodChange;
if (prototype.MoodChange > 0)
amount += prototype.MoodChange * component.GoodMoodMultiplier;
else
amount += prototype.MoodChange * component.BadMoodMultiplier;
}

foreach (var (_, value) in component.UncategorisedEffects)
{
amount += value;
if (value > 0)
amount += value * component.GoodMoodMultiplier;
else
amount += value * component.BadMoodMultiplier;
}

SetMood(uid, amount, component, refresh: true);
Expand Down Expand Up @@ -388,10 +398,10 @@ private void DoMoodThresholdsEffects(EntityUid uid, MoodComponent? component = n
|| component.CurrentMoodThreshold == component.LastThreshold && !force)
return;

var modifier = GetMovementThreshold(component.CurrentMoodThreshold);
var modifier = GetMovementThreshold(component.CurrentMoodThreshold, component);

// Modify mob stats
if (modifier != GetMovementThreshold(component.LastThreshold))
if (modifier != GetMovementThreshold(component.LastThreshold, component))
{
_movementSpeedModifier.RefreshMovementSpeedModifiers(uid);
SetCritThreshold(uid, component, modifier);
Expand Down Expand Up @@ -451,14 +461,15 @@ private MoodThreshold GetMoodThreshold(MoodComponent component, float? moodLevel
return result;
}

private int GetMovementThreshold(MoodThreshold threshold)
private int GetMovementThreshold(MoodThreshold threshold, MoodComponent component)
{
return threshold switch
{
>= MoodThreshold.Good => 1,
<= MoodThreshold.Meh => -1,
_ => 0
};
if (threshold >= component.BuffsMoodThreshold)
return 1;

if (threshold <= component.ConsMoodThreshold)
return -1;

return 0;
}

private string GetMoodName(MoodThreshold threshold)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ namespace Content.Server.Backmen.Traits.Assorted;
public sealed partial class MoodModifyTraitComponent : Component
{
[DataField]
public string? MoodId = null;
public string? MoodId;

[DataField]
public float GoodMoodMultiplier = 1.0f;

[DataField]
public float BadMoodMultiplier = 1.0f;
}
2 changes: 2 additions & 0 deletions Resources/Locale/ru-RU/backmen/mood/mood.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ mood-effect-MobHighPressure = Я чувствую будто воздух сжи

mood-effect-TraitSaturnine = Тут всё очень скучное. Ненавижу эту работу.

mood-effect-TraitFortitude = Мне уже на всё плевать.

mood-effect-Dead = Вы мертвы.

mood-effect-BeingHugged = Люблю когда меня обнимают.
Expand Down
9 changes: 8 additions & 1 deletion Resources/Locale/ru-RU/backmen/trait/OwOAccent.ftl
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

trait-category-mood = Настроение

OwOAccent-name = OwO акцент
OwOAccent-desc = Вы не можете перестать говорить как неко!
trait-fortitude-name = Моральная стойкость
trait-fortitude-desc = Вы не такой эмоциональный человек как остальные, вам плевать на все трудности и радости жизни.
trait-hypomania-name = Гипомания
trait-hypomania-desc = Обычно вам чертвоски весело, но любой негатив вас сильно расстраивает!
trait-depression-name = Депрессия
trait-depression-desc = Чувак, эта вечеринка отстой. Я, блин, ненавижу этих людей.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
id: TraitSaturnine
moodChange: -20

- type: moodEffect
id: TraitFortitude
moodChange: -10

- type: moodEffect
id: Dead
moodChange: -1000
Expand All @@ -59,5 +63,5 @@

- type: moodEffect
id: SurgeryPain
moodChange: -15
timeout: 180
moodChange: -30
timeout: 90
4 changes: 4 additions & 0 deletions Resources/Prototypes/_Backmen/Traits/categories.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- type: traitCategory
id: MoodTraits
name: trait-category-mood
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Требуется добавление локализации для других языков

Ключ локализации 'trait-category-mood' найден только в русской локализации (ru-RU), но отсутствует в других языковых файлах. Необходимо:

  • Добавить ключ 'trait-category-mood' в файлы локализации для других поддерживаемых языков в директории Resources/Locale/
🔗 Analysis chain

Проверка наличия ключа локализации

Необходимо убедиться, что ключ локализации 'trait-category-mood' определен в файлах локализации.


Ключ локализации найден и корректно определен

Ключ локализации 'trait-category-mood' найден в файле локализации для русского языка (ru-RU).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the localization key exists in the localization files
rg "trait-category-mood" Resources/Locale/

Length of output: 126


Script:

#!/bin/bash
# Проверим наличие ключа в других языковых файлах
fd . Resources/Locale/ -t f -e ftl --exec rg -l "trait-category-mood" {}

Length of output: 125

maxTraitPoints: 1
1 change: 0 additions & 1 deletion Resources/Prototypes/_Backmen/Traits/disabilities.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

- type: trait
id: Monolingual
name: trait-monolingual-name
Expand Down
39 changes: 37 additions & 2 deletions Resources/Prototypes/_Backmen/Traits/neutral.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

- type: trait
- type: trait
id: OwOAccent
name: OwOAccent-name
description: OwOAccent-desc
category: SpeechTraits
cost: 1
blacklist:
components:
- BSSDrone #backmen: bssdrone
Expand All @@ -13,3 +14,37 @@
- Felinid
components:
- type: OwOAccent

# for mood haters
- type: trait
id: Fortitude
name: trait-fortitude-name
description: trait-fortitude-desc
category: MoodTraits
cost: 1
components:
- type: MoodModifyTrait
moodId: TraitFortitude
goodMoodMultiplier: 0.5
badMoodMultiplier: 0.5

- type: trait
id: Hypomania
name: trait-hypomania-name
description: trait-hypomania-desc
category: MoodTraits
cost: 1
components:
- type: MoodModifyTrait
moodId: TraitSanguine
badMoodMultiplier: 1.5 # Everything comes with a price.

Comment on lines +31 to +40
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Необходимо добавить множитель для положительного настроения

В реализации черты Hypomania отсутствует goodMoodMultiplier. Наличие только отрицательного множителя 1.5 может сделать эту черту чрезмерно невыгодной для игрока.

Предлагаемые изменения:

  - type: MoodModifyTrait
    moodId: TraitSanguine
+   goodMoodMultiplier: 1.2    # Повышенный положительный эффект для баланса
    badMoodMultiplier: 1.5     # Everything comes with a price.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- type: trait
id: Hypomania
name: trait-hypomania-name
description: trait-hypomania-desc
category: MoodTraits
cost: 1
components:
- type: MoodModifyTrait
moodId: TraitSanguine
badMoodMultiplier: 1.5 # Everything comes with a price.
- type: trait
id: Hypomania
name: trait-hypomania-name
description: trait-hypomania-desc
category: MoodTraits
cost: 1
components:
- type: MoodModifyTrait
moodId: TraitSanguine
goodMoodMultiplier: 1.2 # Повышенный положительный эффект для баланса
badMoodMultiplier: 1.5 # Everything comes with a price.

- type: trait
id: Depression
name: trait-depression-name
description: trait-depression-desc
category: MoodTraits
cost: 1
components:
- type: MoodModifyTrait
moodId: TraitSaturnine
Loading