Important fix for table climbing (#10803)
This commit is contained in:
committed by
GitHub
parent
0e5e3b46c4
commit
84e20049b8
@@ -1,11 +1,14 @@
|
|||||||
using Content.Server.Climbing.Components;
|
using Content.Server.Climbing.Components;
|
||||||
using Content.Server.DoAfter;
|
using Content.Server.DoAfter;
|
||||||
|
using Content.Server.Interaction.Components;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Stunnable;
|
using Content.Server.Stunnable;
|
||||||
|
using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems;
|
||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
using Content.Shared.Body.Components;
|
using Content.Shared.Body.Components;
|
||||||
using Content.Shared.Body.Part;
|
using Content.Shared.Body.Part;
|
||||||
using Content.Shared.Buckle.Components;
|
using Content.Shared.Buckle.Components;
|
||||||
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Climbing;
|
using Content.Shared.Climbing;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.DragDrop;
|
using Content.Shared.DragDrop;
|
||||||
@@ -16,17 +19,21 @@ using Content.Shared.Physics;
|
|||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Physics.Collision.Shapes;
|
using Robust.Shared.Physics.Collision.Shapes;
|
||||||
using Robust.Shared.Physics.Dynamics;
|
using Robust.Shared.Physics.Dynamics;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
|
using SharpZstd.Interop;
|
||||||
|
|
||||||
namespace Content.Server.Climbing;
|
namespace Content.Server.Climbing;
|
||||||
|
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class ClimbSystem : SharedClimbSystem
|
public sealed class ClimbSystem : SharedClimbSystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||||
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||||
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
||||||
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
|
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
|
||||||
@@ -34,6 +41,7 @@ public sealed class ClimbSystem : SharedClimbSystem
|
|||||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||||
[Dependency] private readonly StunSystem _stunSystem = default!;
|
[Dependency] private readonly StunSystem _stunSystem = default!;
|
||||||
|
[Dependency] private readonly AudioSystem _audioSystem = default!;
|
||||||
|
|
||||||
private const string ClimbingFixtureName = "climb";
|
private const string ClimbingFixtureName = "climb";
|
||||||
private const int ClimbingCollisionGroup = (int) (CollisionGroup.TableLayer | CollisionGroup.LowImpassable);
|
private const int ClimbingCollisionGroup = (int) (CollisionGroup.TableLayer | CollisionGroup.LowImpassable);
|
||||||
@@ -80,6 +88,9 @@ public sealed class ClimbSystem : SharedClimbSystem
|
|||||||
if (!args.CanAccess || !args.CanInteract || !_actionBlockerSystem.CanMove(args.User))
|
if (!args.CanAccess || !args.CanInteract || !_actionBlockerSystem.CanMove(args.User))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (component.Bonk && _cfg.GetCVar(CCVars.GameTableBonk))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!TryComp(args.User, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
|
if (!TryComp(args.User, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -102,6 +113,9 @@ public sealed class ClimbSystem : SharedClimbSystem
|
|||||||
if (!TryComp(entityToMove, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
|
if (!TryComp(entityToMove, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (TryBonk(component, user))
|
||||||
|
return;
|
||||||
|
|
||||||
_doAfterSystem.DoAfter(new DoAfterEventArgs(entityToMove, component.ClimbDelay, default, climbable)
|
_doAfterSystem.DoAfter(new DoAfterEventArgs(entityToMove, component.ClimbDelay, default, climbable)
|
||||||
{
|
{
|
||||||
BreakOnTargetMove = true,
|
BreakOnTargetMove = true,
|
||||||
@@ -112,6 +126,33 @@ public sealed class ClimbSystem : SharedClimbSystem
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool TryBonk(ClimbableComponent component, EntityUid user)
|
||||||
|
{
|
||||||
|
if (!component.Bonk)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!_cfg.GetCVar(CCVars.GameTableBonk))
|
||||||
|
{
|
||||||
|
// Not set to always bonk, try clumsy roll.
|
||||||
|
if (!TryComp(user, out ClumsyComponent? clumsy))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!clumsy.RollClumsy(component.BonkClumsyChance))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BONK!
|
||||||
|
|
||||||
|
_audioSystem.PlayPvs(component.BonkSound, component.Owner);
|
||||||
|
|
||||||
|
_stunSystem.TryKnockdown(user, TimeSpan.FromSeconds(component.BonkTime), true);
|
||||||
|
|
||||||
|
if (component.BonkDamage is { } bonkDmg)
|
||||||
|
_damageableSystem.TryChangeDamage(user, bonkDmg, true);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnClimbFinished(EntityUid uid, ClimbingComponent climbing, ClimbFinishedEvent args)
|
private void OnClimbFinished(EntityUid uid, ClimbingComponent climbing, ClimbFinishedEvent args)
|
||||||
{
|
{
|
||||||
Climb(uid, args.User, args.Climbable, climbing: climbing);
|
Climb(uid, args.User, args.Climbable, climbing: climbing);
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Climbing;
|
using Content.Shared.Climbing;
|
||||||
|
using Content.Shared.Damage;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
|
|
||||||
namespace Content.Server.Climbing.Components;
|
namespace Content.Server.Climbing.Components;
|
||||||
|
|
||||||
@@ -12,4 +15,36 @@ public sealed class ClimbableComponent : SharedClimbableComponent
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
[DataField("delay")]
|
[DataField("delay")]
|
||||||
public float ClimbDelay = 0.8f;
|
public float ClimbDelay = 0.8f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If set, people can bonk on this if <see cref="CCVars.GameTableBonk"/> is set or if they are clumsy.
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables] [DataField("bonk")] public bool Bonk = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Chance of bonk triggering if the user is clumsy.
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables] [DataField("bonkClumsyChance")]
|
||||||
|
public float BonkClumsyChance = 0.75f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sound to play when bonking.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="Bonk"/>
|
||||||
|
[ViewVariables] [DataField("bonkSound")]
|
||||||
|
public SoundSpecifier? BonkSound;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How long to stun players on bonk, in seconds.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="Bonk"/>
|
||||||
|
[ViewVariables] [DataField("bonkTime")]
|
||||||
|
public float BonkTime = 2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How much damage to apply on bonk.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="Bonk"/>
|
||||||
|
[ViewVariables] [DataField("bonkDamage")]
|
||||||
|
public DamageSpecifier? BonkDamage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,6 +231,12 @@ namespace Content.Shared.CCVar
|
|||||||
public static readonly CVarDef<int> PanicBunkerMinAccountAge =
|
public static readonly CVarDef<int> PanicBunkerMinAccountAge =
|
||||||
CVarDef.Create("game.panic_bunker.min_account_age", 1440, CVar.SERVERONLY);
|
CVarDef.Create("game.panic_bunker.min_account_age", 1440, CVar.SERVERONLY);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Make people bonk when trying to climb certain objects like tables.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<bool> GameTableBonk =
|
||||||
|
CVarDef.Create("game.table_bonk", false, CVar.SERVERONLY);
|
||||||
|
|
||||||
#if EXCEPTION_TOLERANCE
|
#if EXCEPTION_TOLERANCE
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Amount of times round start must fail before the server is shut down.
|
/// Amount of times round start must fail before the server is shut down.
|
||||||
|
|||||||
9
Resources/Audio/Items/attributions.yml
Normal file
9
Resources/Audio/Items/attributions.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
- files: ["trayhit1.ogg"]
|
||||||
|
license: "CC-BY-SA-3.0"
|
||||||
|
copyright: "Time immemorial"
|
||||||
|
source: "https://github.com/tgstation/tgstation/blob/172b533d0257fcc1f8a05406f1c9fad514c14d88/sound/items/trayhit1.ogg"
|
||||||
|
|
||||||
|
- files: ["trayhit2.ogg"]
|
||||||
|
license: "CC-BY-SA-3.0"
|
||||||
|
copyright: "Time immemorial"
|
||||||
|
source: "https://github.com/tgstation/tgstation/blob/172b533d0257fcc1f8a05406f1c9fad514c14d88/sound/items/trayhit2.ogg"
|
||||||
BIN
Resources/Audio/Items/trayhit1.ogg
Normal file
BIN
Resources/Audio/Items/trayhit1.ogg
Normal file
Binary file not shown.
BIN
Resources/Audio/Items/trayhit2.ogg
Normal file
BIN
Resources/Audio/Items/trayhit2.ogg
Normal file
Binary file not shown.
@@ -27,4 +27,10 @@
|
|||||||
key: state
|
key: state
|
||||||
base: state_
|
base: state_
|
||||||
- type: Climbable
|
- type: Climbable
|
||||||
|
bonk: true
|
||||||
|
bonkDamage:
|
||||||
|
types:
|
||||||
|
Blunt: 4
|
||||||
|
bonkSound: !type:SoundCollectionSpecifier
|
||||||
|
collection: TrayHit
|
||||||
- type: Clickable
|
- type: Clickable
|
||||||
|
|||||||
@@ -216,6 +216,12 @@
|
|||||||
- type: Construction
|
- type: Construction
|
||||||
graph: Table
|
graph: Table
|
||||||
node: TableReinforced
|
node: TableReinforced
|
||||||
|
- type: Climbable
|
||||||
|
# Reinforced tables are extra tough
|
||||||
|
bonkDamage:
|
||||||
|
types:
|
||||||
|
Blunt: 8
|
||||||
|
bonkTime: 3
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: TableGlass
|
id: TableGlass
|
||||||
|
|||||||
5
Resources/Prototypes/SoundCollections/tray.yml
Normal file
5
Resources/Prototypes/SoundCollections/tray.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
- type: soundCollection
|
||||||
|
id: TrayHit
|
||||||
|
files:
|
||||||
|
- /Audio/Items/trayhit1.ogg
|
||||||
|
- /Audio/Items/trayhit2.ogg
|
||||||
Reference in New Issue
Block a user