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

back crawling and chatting in crit #39

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,11 @@ private void SendEntityWhisper(

_replay.RecordServerMessage(new ChatMessage(ChatChannel.Whisper, message, wrappedMessage, GetNetEntity(source), null, MessageRangeHideChatForReplay(range)));

// Stories-Crit-Speech-Start
if (_mobStateSystem.IsCritical(source) && _prototype.TryIndex<DamageTypePrototype>("Asphyxiation", out var asphyxiation))
_damageable.TryChangeDamage(source, new(asphyxiation, 100), true, false);
// Stories-Crit-Speech-End

var ev = new EntitySpokeEvent(source, message, originalMessage, channel, obfuscatedMessage); // Stories-TTS: Spec symbol sanitize
RaiseLocalEvent(source, ev, true);
if (!hideLog)
Expand Down
49 changes: 48 additions & 1 deletion Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
using Content.Shared.Throwing;
using Robust.Shared.Physics.Components;

using Content.Shared.Damage;
using Content.Shared.Humanoid;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;

namespace Content.Shared.Mobs.Systems;

public partial class MobStateSystem
Expand Down Expand Up @@ -46,6 +51,8 @@ private void SubscribeEvents()
SubscribeLocalEvent<MobStateComponent, AttemptPacifiedAttackEvent>(OnAttemptPacifiedAttack);

SubscribeLocalEvent<MobStateComponent, UnbuckleAttemptEvent>(OnUnbuckleAttempt);

SubscribeLocalEvent<MobStateComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeedModifiers); // Stories-Crawling
}

private void OnUnbuckleAttempt(Entity<MobStateComponent> ent, ref UnbuckleAttemptEvent args)
Expand Down Expand Up @@ -73,6 +80,11 @@ private void OnStateExitSubscribers(EntityUid target, MobStateComponent componen
{
case MobState.Alive:
//unused

// Stories-Crawling-Start
if (!_standing.CanCrawl(target))
_standing.Stand(target);
// Stories-Crawling-End
break;
case MobState.Critical:
_standing.Stand(target);
Expand Down Expand Up @@ -144,6 +156,10 @@ private void OnSpeakAttempt(EntityUid uid, MobStateComponent component, SpeakAtt
RemCompDeferred<AllowNextCritSpeechComponent>(uid);
return;
}
// Stories-Crit-Speech-Start
if (component.CurrentState == MobState.Critical)
return;
// Stories-Crit-Speech-End

CheckAct(uid, component, args);
}
Expand All @@ -153,9 +169,13 @@ private void CheckAct(EntityUid target, MobStateComponent component, Cancellable
switch (component.CurrentState)
{
case MobState.Dead:
case MobState.Critical:
args.Cancel();
break;
case MobState.Critical:
if (args is not UpdateCanMoveEvent || !HasComp<HumanoidAppearanceComponent>(target))
args.Cancel();

break;
}
}

Expand Down Expand Up @@ -186,5 +206,32 @@ private void OnAttemptPacifiedAttack(Entity<MobStateComponent> ent, ref AttemptP
args.Cancelled = true;
}

private void OnRefreshMovementSpeedModifiers(EntityUid uid, MobStateComponent component, ref RefreshMovementSpeedModifiersEvent ev)
{
if (!HasComp<HumanoidAppearanceComponent>(uid))
return;

switch (component.CurrentState)
{
case MobState.Critical:
if (!TryComp<DamageableComponent>(uid, out var damageable))
return;

// Stories-Crawling-Start
if (!TryComp<MovementSpeedModifierComponent>(uid, out var speed))
return;

if (!_mobThreshold.TryGetPercentageForState(uid, MobState.Dead, damageable.TotalDamage, out var percentage))
return;

var sprintSpeedModifier = (1 - (float) percentage) * 2 * 0.15f * speed.BaseSprintSpeed;
var walkSpeedModifier = (1 - (float) percentage) * 2 * 0.15f * speed.BaseWalkSpeed;

ev.ModifySpeed(sprintSpeedModifier, walkSpeedModifier);
// Stories-Crawling-End
break;
}
}

#endregion
}
Loading