Skip to content

Commit

Permalink
oracle wrong item message cooldown (#885)
Browse files Browse the repository at this point in the history
no more oracle spam
  • Loading branch information
Guess-My-Name authored Feb 22, 2024
1 parent 4639342 commit b9dd5ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Content.Server/Nyanotrasen/Research/Oracle/OracleComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public sealed partial class OracleComponent : Component
[DataField("barkTime")]
public TimeSpan BarkTime = TimeSpan.FromMinutes(1);

[DataField("rejectAccumulator")]
public float RejectAccumulator;

[DataField("rejectTime")]
public TimeSpan RejectTime = TimeSpan.FromSeconds(5);

[ViewVariables(VVAccess.ReadWrite)]
public EntityPrototype DesiredPrototype = default!;

Expand Down
8 changes: 7 additions & 1 deletion Content.Server/Nyanotrasen/Research/Oracle/OracleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public override void Update(float frameTime)
{
oracle.Accumulator += frameTime;
oracle.BarkAccumulator += frameTime;
oracle.RejectAccumulator += frameTime;
if (oracle.BarkAccumulator >= oracle.BarkTime.TotalSeconds)
{
oracle.BarkAccumulator = 0;
Expand Down Expand Up @@ -120,8 +121,12 @@ private void OnInteractUsing(EntityUid uid, OracleComponent component, InteractU

if (!validItem)
{
if (!HasComp<RefillableSolutionComponent>(args.Used))
if (!HasComp<RefillableSolutionComponent>(args.Used) &&
component.RejectAccumulator >= component.RejectTime.TotalSeconds)
{
component.RejectAccumulator = 0;
_chat.TrySendInGameICMessage(uid, _random.Pick(component.RejectMessages), InGameICChatType.Speak, true);
}
return;
}

Expand Down Expand Up @@ -186,6 +191,7 @@ private void NextItem(OracleComponent component)
{
component.Accumulator = 0;
component.BarkAccumulator = 0;
component.RejectAccumulator = 0;
var protoString = GetDesiredItem(component);
if (_prototypeManager.TryIndex<EntityPrototype>(protoString, out var proto))
component.DesiredPrototype = proto;
Expand Down

0 comments on commit b9dd5ed

Please sign in to comment.