Important fix for table climbing (#10803)

This commit is contained in:
Pieter-Jan Briers
2022-08-25 15:41:37 +02:00
committed by GitHub
parent 0e5e3b46c4
commit 84e20049b8
9 changed files with 110 additions and 2 deletions

View File

@@ -1,11 +1,14 @@
using Content.Server.Climbing.Components;
using Content.Server.DoAfter;
using Content.Server.Interaction.Components;
using Content.Server.Popups;
using Content.Server.Stunnable;
using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems;
using Content.Shared.ActionBlocker;
using Content.Shared.Body.Components;
using Content.Shared.Body.Part;
using Content.Shared.Buckle.Components;
using Content.Shared.CCVar;
using Content.Shared.Climbing;
using Content.Shared.Damage;
using Content.Shared.DragDrop;
@@ -16,17 +19,21 @@ using Content.Shared.Physics;
using Content.Shared.Popups;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Configuration;
using Robust.Shared.GameStates;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player;
using SharpZstd.Interop;
namespace Content.Server.Climbing;
[UsedImplicitly]
public sealed class ClimbSystem : SharedClimbSystem
{
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = 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 SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly StunSystem _stunSystem = default!;
[Dependency] private readonly AudioSystem _audioSystem = default!;
private const string ClimbingFixtureName = "climb";
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))
return;
if (component.Bonk && _cfg.GetCVar(CCVars.GameTableBonk))
return;
if (!TryComp(args.User, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
return;
@@ -102,6 +113,9 @@ public sealed class ClimbSystem : SharedClimbSystem
if (!TryComp(entityToMove, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
return;
if (TryBonk(component, user))
return;
_doAfterSystem.DoAfter(new DoAfterEventArgs(entityToMove, component.ClimbDelay, default, climbable)
{
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)
{
Climb(uid, args.User, args.Climbable, climbing: climbing);

View File

@@ -1,4 +1,7 @@
using Content.Shared.CCVar;
using Content.Shared.Climbing;
using Content.Shared.Damage;
using Robust.Shared.Audio;
namespace Content.Server.Climbing.Components;
@@ -12,4 +15,36 @@ public sealed class ClimbableComponent : SharedClimbableComponent
[ViewVariables]
[DataField("delay")]
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;
}

View File

@@ -231,6 +231,12 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<int> PanicBunkerMinAccountAge =
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
/// <summary>
/// Amount of times round start must fail before the server is shut down.

View 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"

Binary file not shown.

Binary file not shown.

View File

@@ -27,4 +27,10 @@
key: state
base: state_
- type: Climbable
bonk: true
bonkDamage:
types:
Blunt: 4
bonkSound: !type:SoundCollectionSpecifier
collection: TrayHit
- type: Clickable

View File

@@ -45,7 +45,7 @@
- type: Construction
graph: Table
node: TableFrame
- type: entity
id: CounterWoodFrame
parent: BaseStructure
@@ -216,6 +216,12 @@
- type: Construction
graph: Table
node: TableReinforced
- type: Climbable
# Reinforced tables are extra tough
bonkDamage:
types:
Blunt: 8
bonkTime: 3
- type: entity
id: TableGlass
@@ -490,7 +496,7 @@
- type: Construction
graph: Table
node: CounterWood
- type: entity
id: TableCounterMetal
parent: CounterMetalFrame

View File

@@ -0,0 +1,5 @@
- type: soundCollection
id: TrayHit
files:
- /Audio/Items/trayhit1.ogg
- /Audio/Items/trayhit2.ogg