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

Resomi #27

Merged
merged 15 commits into from
Nov 25, 2024
  •  
  •  
  •  
11 changes: 11 additions & 0 deletions Content.Server/Chat/ChatComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Content.Server.Chat;

/// <summary>
/// Modifaer for entity to expand whisper radius
AwareFoxy marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
AwareFoxy marked this conversation as resolved.
Show resolved Hide resolved
[RegisterComponent]
public sealed partial class ChatComponent : Component
{
[DataField("whisperPersonalRange")]
public int WhisperPersonalRange = 2;
AwareFoxy marked this conversation as resolved.
Show resolved Hide resolved
}
5 changes: 4 additions & 1 deletion Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,13 @@ private void SendEntityWhisper(
continue;
listener = session.AttachedEntity.Value;

var listenerComp = CompOrNull<ChatComponent>(listener); //Corvax-Next-Resomi modifaer for whisper range

if (MessageRangeCheck(session, data, range) != MessageRangeCheckResult.Full)
continue; // Won't get logged to chat, and ghosts are too far away to see the pop-up, so we just won't send it to them.

if (data.Range <= WhisperClearRange)
if ((listenerComp != null && data.Range <= listenerComp.WhisperPersonalRange)
|| (listenerComp == null && data.Range <= WhisperClearRange)) //Corvax-Next-Resomi modifaer for whisper range
AwareFoxy marked this conversation as resolved.
Show resolved Hide resolved
_chatManager.ChatMessageToOne(ChatChannel.Whisper, message, wrappedMessage, source, false, session.Channel);
//If listener is too far, they only hear fragments of the message
else if (_examineSystem.InRangeUnOccluded(source, listener, WhisperMuffledRange))
Expand Down
6 changes: 6 additions & 0 deletions Content.Server/Flash/FlashSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ public void Flash(EntityUid target,
bool melee = false,
TimeSpan? stunDuration = null)
{
//CorvaxNext duration modifier for resomi
AwareFoxy marked this conversation as resolved.
Show resolved Hide resolved
if (TryComp<FlashModifierComponent>(target, out var flashModifier))
{
flashDuration *= flashModifier.Modifier;
}

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

Expand Down
108 changes: 108 additions & 0 deletions Content.Server/_CorvaxNext/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._CorvaxNext.Resomi;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared._CorvaxNext.Resomi.Abilities;
using Content.Shared.Damage.Components;
using Robust.Shared.Physics;

namespace Content.Server._CorvaxNext.Resomi.Abilities;

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

private Entity<BaseActionComponent> action;

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)
FireNameFN marked this conversation as resolved.
Show resolved Hide resolved
{
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.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);

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;
AwareFoxy marked this conversation as resolved.
Show resolved Hide resolved

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._CorvaxNext.Speech.Components;

[RegisterComponent]
public sealed partial class ResomiAccentComponent : Component;
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System.Text.RegularExpressions;
using Content.Server._CorvaxNext.Speech.Components;
using Content.Server.Speech;
using Robust.Shared.Random;

namespace Content.Server._CorvaxNext.Speech.EntitySystems;

public sealed class ResomiAccentSystem : EntitySystem
{

[Dependency] private readonly IRobustRandom _random = default!;

public override void Initialize()
{
base.Initialize();
AwareFoxy marked this conversation as resolved.
Show resolved Hide resolved
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;
}
}
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;
pofitlo-Git marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -37,6 +37,8 @@ public sealed partial class WieldableComponent : Component
public string? WieldedInhandPrefix = "wielded";

public string? OldInhandPrefix = null;

public EntityUid? User = null; // Corvax-Next-Resomi
}

[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 @@ -20,6 +20,7 @@
using Robust.Shared.Audio.Systems;
using Robust.Shared.Network;
using Robust.Shared.Timing;
using Content.Shared._CorvaxNext.Resomi.Abilities;

namespace Content.Shared.Wieldable;

Expand Down Expand Up @@ -109,7 +110,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 @@ -257,6 +258,8 @@ public bool TryWield(EntityUid used, WieldableComponent component, EntityUid use
var othersMessage = Loc.GetString("wieldable-component-successful-wield-other", ("user", Identity.Entity(user, EntityManager)), ("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._CorvaxNext.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._CorvaxNext.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) //fix it.... maybe.... -_-.... or idk
return;
AwareFoxy marked this conversation as resolved.
Show resolved Hide resolved

_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,11 @@
namespace Content.Shared._CorvaxNext.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
pofitlo-Git marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
[RegisterComponent]
public sealed partial class WeaponsUseInabilityComponent : Component
{
}
pofitlo-Git marked this conversation as resolved.
Show resolved Hide resolved
pofitlo-Git marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading