Gods part 2 (#1420)

* spooky scary patreons

* Update CP14ReligionSystem.cs

* goodbye radio channel

* gods? no! Mana parasites! Muahahaha

* Update gods.yml

* Update primordial.yml
This commit is contained in:
Red
2025-06-13 19:21:09 +03:00
committed by GitHub
parent 41689de5aa
commit b932d56f15
15 changed files with 166 additions and 43 deletions

View File

@@ -1,3 +1,4 @@
using System.Text;
using Content.Shared._CP14.Religion.Systems;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
@@ -64,6 +65,9 @@ public sealed partial class CP14ReligionEntityWindow : DefaultWindow
private string GetStatusText(CP14ReligionEntityUiState state)
{
return Loc.GetString("cp14-god-ui-follower-percentage", ("count", state.FollowerPercentage * 100));
var sb = new StringBuilder();
sb.Append(Loc.GetString("cp14-god-ui-follower-percentage", ("count", state.FollowerPercentage * 100)) + "\n");
sb.Append(Loc.GetString("cp14-god-ui-mana-percentage", ("count", state.ManaPercentage * 100)) + "\n");
return sb.ToString();
}
}

View File

@@ -1,17 +1,15 @@
using System.Globalization;
using System.Linq;
using System.Text;
using Content.Server._CP14.Religion;
using Content.Server.Administration.Logs;
using Content.Server.Administration.Managers;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking;
using Content.Server.Players.RateLimiting;
using Content.Server.Radio.EntitySystems;
using Content.Server.Speech.Prototypes;
using Content.Server.Speech.EntitySystems;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Shared._CP14.Religion.Components;
using Content.Shared.ActionBlocker;
using Content.Shared.Administration;
using Content.Shared.CCVar;
@@ -62,9 +60,6 @@ public sealed partial class ChatSystem : SharedChatSystem
[Dependency] private readonly ReplacementAccentSystem _wordreplacement = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
[Dependency] private readonly ExamineSystemShared _examineSystem = default!;
//CP14
[Dependency] private readonly RadioSystem _radio = default!;
//CP14 end
public const int VoiceRange = 10; // how far voice goes in world units
public const int WhisperClearRange = 2; // how far whisper goes while still being understandable, in world units
@@ -179,15 +174,6 @@ public sealed partial class ChatSystem : SharedChatSystem
bool ignoreActionBlocker = false
)
{
//CP14 Zone
if (HasComp<CP14ReligionEntityComponent>(source))
{
TryProccessRadioMessage(source, message, out var modMessage, out var channel);
_radio.SendRadioMessage(source, modMessage, "CP14Gods", source);
return;
}
//CP14 Zone end
if (HasComp<GhostComponent>(source))
{
// Ghosts can only send dead chat messages, so we'll forward it to InGame OOC.
@@ -207,6 +193,13 @@ public sealed partial class ChatSystem : SharedChatSystem
if (!CanSendInGame(message, shell, player))
return;
//CP14 Prevent god from default speaking. In waiting of chatcode refactor
var ev = new CP14SpokeAttemptEvent(message, desiredType, player);
RaiseLocalEvent(source, ev);
if (ev.Cancelled)
return;
//CP14 end
ignoreActionBlocker = CheckIgnoreSpeechBlocker(source, ignoreActionBlocker);
// this method is a disaster

View File

@@ -1,5 +1,7 @@
using Content.Shared._CP14.MagicEnergy.Components;
using Content.Shared._CP14.Religion.Components;
using Content.Shared._CP14.Religion.Systems;
using Content.Shared.FixedPoint;
using Content.Shared.Follower;
using Robust.Server.GameObjects;
@@ -70,6 +72,12 @@ public sealed partial class CP14ReligionGodSystem
ent.Comp.FollowerPercentage = followerPercentage;
Dirty(ent);
_userInterface.SetUiState(ent.Owner, CP14ReligionEntityUiKey.Key, new CP14ReligionEntityUiState(altars, followers, followerPercentage));
FixedPoint2 manaPercentage = 0f;
if (TryComp<CP14MagicEnergyContainerComponent>(ent, out var manaContainerComponent))
{
manaPercentage = manaContainerComponent.Energy / manaContainerComponent.MaxEnergy;
}
_userInterface.SetUiState(ent.Owner, CP14ReligionEntityUiKey.Key, new CP14ReligionEntityUiState(altars, followers, followerPercentage, (float)manaPercentage));
}
}

View File

@@ -1,5 +1,8 @@
using Content.Server._CP14.MagicEnergy;
using Content.Server.Chat.Managers;
using Content.Server.Chat.Systems;
using Content.Server.Speech;
using Content.Shared._CP14.MagicEnergy.Components;
using Content.Shared._CP14.Religion.Components;
using Content.Shared._CP14.Religion.Prototypes;
using Content.Shared._CP14.Religion.Systems;
@@ -8,13 +11,18 @@ using Robust.Server.GameStates;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
namespace Content.Server._CP14.Religion;
public sealed partial class CP14ReligionGodSystem : CP14SharedReligionGodSystem
{
[Dependency] private readonly IChatManager _chat = default!;
[Dependency] private readonly ChatSystem _chatSys = default!;
[Dependency] private readonly PvsOverrideSystem _pvs = default!;
[Dependency] private readonly CP14MagicEnergySystem _magicEnergy = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
public override void Initialize()
{
@@ -28,10 +36,57 @@ public sealed partial class CP14ReligionGodSystem : CP14SharedReligionGodSystem
SubscribeLocalEvent<CP14ReligionEntityComponent, ComponentShutdown>(OnGodShutdown);
SubscribeLocalEvent<CP14ReligionEntityComponent, PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<CP14ReligionEntityComponent, PlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<CP14ReligionSpeakerComponent, CP14SpokeAttemptEvent>(OnSpokeAttempt);
SubscribeLocalEvent<CP14ReligionAltarComponent, ListenEvent>(OnListen);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
var query = EntityQueryEnumerator<CP14ReligionFollowerComponent, CP14MagicEnergyContainerComponent>();
while (query.MoveNext(out var uid, out var follower, out var energy))
{
if (follower.NextUpdateTime >= _gameTiming.CurTime)
continue;
if (follower.Religion is null)
continue;
follower.NextUpdateTime = _gameTiming.CurTime + TimeSpan.FromSeconds(follower.ManaTransferDelay);
foreach (var god in GetGods(follower.Religion.Value))
{
_magicEnergy.TransferEnergy((uid, energy), god.Owner, follower.EnergyToGodTransfer, out _, out _, safe: true);
}
}
}
private void OnSpokeAttempt(Entity<CP14ReligionSpeakerComponent> ent, ref CP14SpokeAttemptEvent args)
{
args.Cancel();
if (!TryComp<CP14ReligionEntityComponent>(ent, out var god) || god.Religion is null)
return;
if (ent.Comp.RestrictedReligionZone && !InVision(ent, (ent, god)))
return;
_magicEnergy.ChangeEnergy(ent.Owner, -ent.Comp.ManaCost, out _, out _);
var speaker = Spawn(ent.Comp.Speaker);
_transform.DropNextTo(speaker, ent.Owner);
var message = args.Message;
var type = args.Type;
Timer.Spawn(333,
() =>
{
_chatSys.TrySendInGameICMessage(speaker, message, type, ChatTransmitRange.Normal, nameOverride: MetaData(ent).EntityName, ignoreActionBlocker: true);
});
}
private void OnObserverHandleState(Entity<CP14ReligionObserverComponent> ent, ref AfterAutoHandleStateEvent args)
{
var query = EntityQueryEnumerator<CP14ReligionEntityComponent>();
@@ -175,3 +230,11 @@ public sealed partial class CP14ReligionGodSystem : CP14SharedReligionGodSystem
AddPvsOverrides(ent);
}
}
public sealed class CP14SpokeAttemptEvent(string message, InGameICChatType type, ICommonSession? player) : CancellableEntityEventArgs
{
public string Message = message;
public InGameICChatType Type = type;
public ICommonSession? Player = player;
}

View File

@@ -1,5 +1,6 @@
using Content.Shared._CP14.Religion.Prototypes;
using Content.Shared._CP14.Religion.Systems;
using Content.Shared.FixedPoint;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
@@ -22,4 +23,22 @@ public sealed partial class CP14ReligionFollowerComponent : Component
[DataField]
public EntityUid? RenounceAction;
/// <summary>
/// how much energy does the entity transfer to its god
/// </summary>
[DataField]
public FixedPoint2 EnergyToGodTransfer = 0.5f;
/// <summary>
/// how often will the entity transfer mana to its patreon
/// </summary>
[DataField]
public float ManaTransferDelay = 3f;
/// <summary>
/// the time of the next magic energy change
/// </summary>
[DataField]
public TimeSpan NextUpdateTime { get; set; } = TimeSpan.Zero;
}

View File

@@ -0,0 +1,28 @@
using Content.Shared._CP14.Religion.Systems;
using Content.Shared.FixedPoint;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.Religion.Components;
/// <summary>
/// Disables standard communication. Instead, attempts to say anything will consume mana, will be limited by the zone
/// of influence of religion, and will be spoken through the created entity of the “speaker.”
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(CP14SharedReligionGodSystem))]
public sealed partial class CP14ReligionSpeakerComponent : Component
{
[DataField]
public FixedPoint2 ManaCost = 5f;
[DataField(required: true)]
public EntProtoId Speaker;
/// <summary>
/// You can only talk within the sphere of influence of religion.
/// </summary>
[DataField]
public bool RestrictedReligionZone = true;
}

View File

@@ -9,11 +9,12 @@ public enum CP14ReligionEntityUiKey
}
[Serializable, NetSerializable]
public sealed class CP14ReligionEntityUiState(Dictionary<NetEntity, string> altars, Dictionary<NetEntity, string> followers, float followerPercentage) : BoundUserInterfaceState
public sealed class CP14ReligionEntityUiState(Dictionary<NetEntity, string> altars, Dictionary<NetEntity, string> followers, float followerPercentage, float manaPercentage) : BoundUserInterfaceState
{
public Dictionary<NetEntity, string> Altars = altars;
public Dictionary<NetEntity, string> Followers = followers;
public float FollowerPercentage = followerPercentage;
public float ManaPercentage = manaPercentage;
}
[Serializable, NetSerializable]

View File

@@ -1 +0,0 @@
cp14-chat-radio-gods = Divine

View File

@@ -11,6 +11,7 @@ cp14-god-ui-title = Fast Travel
cp14-god-ui-follower = Followers
cp14-god-ui-altars = Altars
cp14-god-ui-follower-percentage = Follower percentage: {$count}%
cp14-god-ui-mana-percentage = Divine energy: {$count}%
cp14-altar-become-follower = Become a follower
cp14-altar-become-follower-desc = You offer yourself into the service of your patron. If he agrees, your bond will be strengthened.

View File

@@ -1 +0,0 @@
cp14-chat-radio-gods = Божественный

View File

@@ -11,6 +11,7 @@ cp14-god-ui-title = Быстрое перемещение
cp14-god-ui-follower = Последователи
cp14-god-ui-altars = Алтари
cp14-god-ui-follower-percentage = Процент последователей: {$count}%
cp14-god-ui-mana-percentage = Божественная энергия: {$count}%
cp14-altar-become-follower = Стать последователем
cp14-altar-become-follower-desc = Вы предлагаете себя в службу покровителю. Если он согласится, ваша связь укрепится.

View File

@@ -0,0 +1,21 @@
- type: entity
id: CP14LumeraSpeakImpact
categories: [ ForkFiltered ]
parent: CP14BaseMagicImpact
save: false
components:
- type: PointLight
color: "#3843a8"
enabled: true
radius: 5
energy: 4
netsync: false
- type: Sprite
layers:
- state: stars
color: "#3843a8"
shader: unshaded
- type: LightFade
duration: 1
- type: TimedDespawn
lifetime: 2

View File

@@ -38,8 +38,8 @@
- type: CP14ReligionVision
- type: CP14MagicEnergyContainer
magicAlert: CP14MagicEnergy
maxEnergy: 1000
energy: 1000
maxEnergy: 500
energy: 500
unsafeSupport: true
- type: Damageable
damageContainer: CP14Spectral
@@ -66,18 +66,9 @@
types:
CP14ManaDepletion: 1
- type: CP14MagicEnergyDraw
energy: -3
delay: 2 # 10m to empty
energy: -1.5
delay: 3
safe: false
- type: IntrinsicRadioTransmitter
channels:
- CP14Gods
- type: IntrinsicRadioReceiver
- type: ActiveRadio
receiveAllChannels: true
globalReceive: true
channels:
- CP14Gods
- type: CP14SpellStorage
grantAccessToSelf: true
spells:
@@ -135,4 +126,6 @@
- type: IntrinsicUI
uis:
enum.CP14ReligionEntityUiKey.Key:
toggleAction: CP14ActionSpellGodLumeraWarp
toggleAction: CP14ActionSpellGodLumeraWarp
- type: CP14ReligionSpeaker
speaker: CP14LumeraSpeakImpact

View File

@@ -12,7 +12,7 @@
religion: Lumera
- type: CP14ReligionObserver
observation:
Lumera: 25
Lumera: 10
- type: SpawnPoint
job_id: CP14GodLumera
@@ -30,6 +30,6 @@
religion: Merkas
- type: CP14ReligionObserver
observation:
Merkas: 25
Merkas: 10
- type: SpawnPoint
job_id: CP14GodMerkas

View File

@@ -1,7 +0,0 @@
- type: radioChannel
id: CP14Gods
name: cp14-chat-radio-gods
keycode: 'g'
frequency: 666
color: "#fad634"
longRange: true