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

[Port] Resomi #172

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ private void SendEntityWhisper(
// Result is the intermediate message derived from the perceived one via obfuscation
// Wrapped message is the result wrapped in an "x says y" string
string result, wrappedMessage;
if (data.Range <= WhisperClearRange)
if (data.Range <= (TryComp<ChatModifierComponent>(listener, out var modifier) ? modifier.WhisperListeningRange : WhisperClearRange)) // WWDP-Edit
{
// Scenario 1: the listener can clearly understand the message
result = perceivedMessage;
Expand Down
7 changes: 7 additions & 0 deletions Content.Server/Flash/FlashSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ public void Flash(EntityUid target,
if (!Resolve(target, ref flashable, false))
return;

// WWDP-Start
if (TryComp<FlashModifierComponent>(target, out var flashModifier))
{
flashDuration *= flashModifier.Modifier;
}
// WWDP-End

var attempt = new FlashAttemptEvent(target, user, used);
RaiseLocalEvent(target, attempt, true);

Expand Down
108 changes: 108 additions & 0 deletions Content.Server/_White/Resomi/Abilities/AgillitySkillSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
using Content.Shared.Actions;
using Content.Shared.Alert;
using Content.Shared.Maps;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Timing;
using Content.Shared._White.Resomi;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared._White.Resomi.Abilities;
using Content.Shared.Damage.Components;
using Robust.Shared.Physics;

namespace Content.Server._White.Resomi.Abilities;

public sealed class AgillitySkillSystem : SharedAgillitySkillSystem
{
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!;

private Entity<BaseActionComponent> _action = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AgillitySkillComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<AgillitySkillComponent, SwitchAgillityActionEvent>(SwitchAgility);
SubscribeLocalEvent<AgillitySkillComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
}

private void OnComponentInit(Entity<AgillitySkillComponent> ent, ref ComponentInit args)
{
_actionsSystem.AddAction(ent.Owner, ref ent.Comp.SwitchAgilityActionEntity, ent.Comp.SwitchAgilityAction, ent.Owner);
}

private void SwitchAgility(Entity<AgillitySkillComponent> ent, ref SwitchAgillityActionEvent args)
{
_action = args.Action!;

if (!ent.Comp.Active)
{
ActivateAgility(ent, _action!);
}
else
{
DeactivateAgility(ent.Owner, ent.Comp, _action!);
}
}

private void ActivateAgility(Entity<AgillitySkillComponent> ent, Entity<BaseActionComponent> action)
{
if (!TryComp<MovementSpeedModifierComponent>(ent.Owner, out var comp))
return;

_popup.PopupEntity(Loc.GetString("agility-activated-massage"), ent.Owner, ent.Owner);

ent.Comp.SprintSpeedCurrent += ent.Comp.SprintSpeedModifier; // adding a modifier to the base running speed
_movementSpeedModifier.RefreshMovementSpeedModifiers(ent.Owner);

ent.Comp.Active = !ent.Comp.Active;

var ev = new SwitchAgillity(action, ent.Comp.Active);
RaiseLocalEvent(ent.Owner, ref ev);
}

private void DeactivateAgility(EntityUid uid, AgillitySkillComponent component, Entity<BaseActionComponent> action)
{
if (!TryComp<MovementSpeedModifierComponent>(uid, out var comp))
return;

_popup.PopupEntity(Loc.GetString("agility-deactivated-massage"), uid, uid);

component.SprintSpeedCurrent = 1f; // return the base running speed to normal
_movementSpeedModifier.RefreshMovementSpeedModifiers(uid);

_actions.SetCooldown(action.Owner, component.CooldownDelay);

component.Active = !component.Active;

var ev = new SwitchAgillity(action, component.Active);
RaiseLocalEvent(uid, ref ev);
}

private void OnRefreshMovespeed(Entity<AgillitySkillComponent> ent, ref RefreshMovementSpeedModifiersEvent args)
{
args.ModifySpeed(1f, ent.Comp.SprintSpeedCurrent);
}

public override void Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<AgillitySkillComponent>();
while (query.MoveNext(out var uid, out var resomiComp))
{
if (!TryComp<StaminaComponent>(uid, out var stamina)
|| !resomiComp.Active
|| Timing.CurTime < resomiComp.NextUpdateTime)
continue;

resomiComp.NextUpdateTime = Timing.CurTime + resomiComp.UpdateRate;

_stamina.TryTakeStamina(uid, resomiComp.StaminaDamagePassive);
if (stamina.StaminaDamage > stamina.CritThreshold * 0.50f)
DeactivateAgility(uid, resomiComp, _action!);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace Content.Server._White.Speech.Components;

[RegisterComponent]
public sealed partial class ResomiAccentComponent : Component;
61 changes: 61 additions & 0 deletions Content.Server/_White/Speech/EntitySystems/ResomiAccentSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System.Text.RegularExpressions;
using Content.Server._White.Speech.Components;
using Content.Server.Speech;
using Robust.Shared.Random;

namespace Content.Server._White.Speech.EntitySystems;

public sealed class ResomiAccentSystem : EntitySystem
{

[Dependency] private readonly IRobustRandom _random = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ResomiAccentComponent, AccentGetEvent>(OnAccent);
}

private void OnAccent(EntityUid uid, ResomiAccentComponent component, AccentGetEvent args)
{
var message = args.Message;

// ш => шшш
message = Regex.Replace(
message,
"ш+",
_random.Pick(new List<string>() { "шш", "шшш" })
);
// Ш => ШШШ
message = Regex.Replace(
message,
"Ш+",
_random.Pick(new List<string>() { "ШШ", "ШШШ" })
);
// ч => щщщ
message = Regex.Replace(
message,
"ч+",
_random.Pick(new List<string>() { "щщ", "щщщ" })
);
// Ч => ЩЩЩ
message = Regex.Replace(
message,
"Ч+",
_random.Pick(new List<string>() { "ЩЩ", "ЩЩЩ" })
);
// р => ррр
message = Regex.Replace(
message,
"р+",
_random.Pick(new List<string>() { "рр", "ррр" })
);
// Р => РРР
message = Regex.Replace(
message,
"Р+",
_random.Pick(new List<string>() { "РР", "РРР" })
);
args.Message = message;
}
}
10 changes: 10 additions & 0 deletions Content.Shared/Chat/ChatModifierComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Content.Shared.Chat;
/// <summary>
/// Corvax-Next-Resomi
/// </summary>
[RegisterComponent]
public sealed partial class ChatModifierComponent : Component
{
[DataField("whisperListeningRange")]
public int WhisperListeningRange = SharedChatSystem.WhisperClearRange;
}
13 changes: 13 additions & 0 deletions Content.Shared/Flash/Components/FlashModifierComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Content.Shared.Flash.Components;


/// <summary>
/// Corvax-Next-Resomi
/// </summary>

[RegisterComponent]
public sealed partial class FlashModifierComponent : Component
{
[DataField]
public float Modifier = 1f;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Systems;
using Robust.Shared.Audio;

Expand Down
2 changes: 2 additions & 0 deletions Content.Shared/Wieldable/Components/WieldableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public sealed partial class WieldableComponent : Component
[DataField]
public bool AltUseInHand = false;
// WD EDIT END

public EntityUid? User = null;
}

[Serializable, NetSerializable]
Expand Down
5 changes: 4 additions & 1 deletion Content.Shared/Wieldable/WieldableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Content.Shared.Wieldable.Components;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Timing;
using Content.Shared._White.Resomi.Abilities;

namespace Content.Shared.Wieldable;

Expand Down Expand Up @@ -106,7 +107,7 @@ private void OnDeselectWieldable(EntityUid uid, WieldableComponent component, Ha
private void OnGunRefreshModifiers(Entity<GunWieldBonusComponent> bonus, ref GunRefreshModifiersEvent args)
{
if (TryComp(bonus, out WieldableComponent? wield) &&
wield.Wielded)
wield.Wielded && !HasComp<WeaponsUseInabilityComponent>(wield.User)) //Corvax-Next-Resomi
{
args.MinAngle += bonus.Comp.MinAngle;
args.MaxAngle += bonus.Comp.MaxAngle;
Expand Down Expand Up @@ -269,6 +270,8 @@ public bool TryWield(EntityUid used, WieldableComponent component, EntityUid use
var othersMessage = Loc.GetString("wieldable-component-successful-wield-other", ("user", user), ("item", used));
_popupSystem.PopupPredicted(selfMessage, othersMessage, user, user);

component.User = user; //Corvax-Next-Resomi

var targEv = new ItemWieldedEvent();
RaiseLocalEvent(used, ref targEv);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Shared._White.Resomi.Abilities;

[RegisterComponent, NetworkedComponent]
[AutoGenerateComponentState]
public sealed partial class AgillitySkillComponent : Component
{
[AutoNetworkedField, DataField]
public Dictionary<string, int> DisabledJumpUpFixtureMasks = new();
[AutoNetworkedField, DataField]
public Dictionary<string, int> DisabledJumpDownFixtureMasks = new();

[DataField("active")]
public bool Active = false;

/// <summary>
/// if we want the ability to not give the opportunity to jump on the tables and only accelerate
/// </summary>
[DataField("jumpEnabled")]
public bool JumpEnabled = true;

[DataField("switchAgilityAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? SwitchAgilityAction = "SwitchAgilityAction";

[DataField("switchAgilityActionEntity")] public EntityUid? SwitchAgilityActionEntity;

/// <summary>
/// how much stamina will be spent for each jump
/// </summary>
[DataField("staminaDamageOnJump")]
public float StaminaDamageOnJump = 10f;

/// <summary>
/// how much stamina will be passive spent while abilitty is activated
/// </summary>
[DataField("staminaDamagePassive")]
public float StaminaDamagePassive = 3f;

[DataField("sprintSpeedModifier")]
public float SprintSpeedModifier = 0.1f; //+10%
public float SprintSpeedCurrent = 1f;

/// <summary>
/// once in how many seconds is our stamina taken away while the ability is on
/// </summary>
[DataField("delay")]
public double Delay = 1.0;
public TimeSpan UpdateRate => TimeSpan.FromSeconds(Delay);
public TimeSpan NextUpdateTime;

/// <summary>
/// cooldown of ability. Called when the ability is disabled
/// </summary>
[DataField("cooldown")]
public double Cooldown = 20.0;
public TimeSpan CooldownDelay => TimeSpan.FromSeconds(Cooldown);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Robust.Shared.Timing;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Physics;
using Content.Shared.Physics;
using Content.Shared.Popups;
using Robust.Shared.Physics.Events;
using Robust.Shared.Log;
using Content.Shared.Climbing.Systems;
using Content.Shared.Damage.Systems;
using Content.Shared.Actions;

namespace Content.Shared._White.Resomi.Abilities;

public abstract class SharedAgillitySkillSystem : EntitySystem
{
[Dependency] protected readonly IGameTiming Timing = default!;
[Dependency] protected readonly SharedPopupSystem _popup = default!;
[Dependency] protected readonly ClimbSystem _climb = default!;
[Dependency] protected readonly StaminaSystem _stamina = default!;
[Dependency] protected readonly SharedActionsSystem _actions = default!;

protected const int BaseCollisionGroup = (int)(CollisionGroup.MobMask);

public override void Initialize()
{
SubscribeLocalEvent<AgillitySkillComponent, StartCollideEvent>(DoJump);
SubscribeLocalEvent<AgillitySkillComponent, SwitchAgillity>(OnHandleStateChange);
}

private void DoJump(Entity<AgillitySkillComponent> ent, ref StartCollideEvent args)
{
if (!ent.Comp.Active || !ent.Comp.JumpEnabled
|| args.OurFixture.CollisionMask != BaseCollisionGroup
|| args.OtherFixture.CollisionMask != (int)CollisionGroup.TableMask)
return;

_stamina.TryTakeStamina(ent.Owner, ent.Comp.StaminaDamageOnJump);
_climb.ForciblySetClimbing(ent.Owner, args.OtherEntity);
}

private void OnHandleStateChange(Entity<AgillitySkillComponent> ent, ref SwitchAgillity args)
{
_actions.SetToggled(args.action.Owner, args.toggled);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Content.Shared._White.Resomi.Abilities;


/// <summary>
/// It does not allow you to fire a weapon that requires two hands.
/// Increases the spread, as if shooting was conducted from one hand.
/// </summary>
[RegisterComponent]
public sealed partial class WeaponsUseInabilityComponent : Component;
15 changes: 15 additions & 0 deletions Content.Shared/_White/Resomi/SharedResomi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Content.Shared.Actions;
using Content.Shared.DoAfter;
using Robust.Shared.Serialization;

namespace Content.Shared._White.Resomi;

public sealed partial class SwitchAgillityActionEvent : InstantActionEvent;

/// <summary>
/// Rises when the action state changes
/// </summary>
/// <param name="action"> Entity of Action that we want change the state</param>
/// <param name="toggled"> </param>
[ByRefEvent]
public readonly record struct SwitchAgillity(Entity<BaseActionComponent> action, bool toggled);
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading