Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

GrapplingHook as a rope (just for real test) #330

Merged
merged 11 commits into from
Jun 20, 2024
8 changes: 4 additions & 4 deletions Content.Client/Weapons/Misc/GrapplingGunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public override void Update(float frameTime)
{
return;
}

if (distance.MaxLength <= distance.MinLength)
return;

// Corvax Frontier start
// if (distance.MaxLength <= distance.MinLength)
// return;
// Corvax Frontier end
var reelKey = _input.CmdStates.GetState(EngineKeyFunctions.UseSecondary) == BoundKeyState.Down;

if (!TryComp<CombatModeComponent>(local, out var combatMode) ||
Expand Down
25 changes: 19 additions & 6 deletions Content.Shared/Weapons/Misc/SharedGrapplingGunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ public abstract class SharedGrapplingGunSystem : EntitySystem
[Dependency] private readonly SharedPhysicsSystem _physics = default!;

public const string GrapplingJoint = "grappling";

public const float ReelRate = 2.5f;
public const float MaxGrappleDistance = 20.0f; // Maximum distance for the grappling hook - Corvax Frontier
public const float ExtendRate = 2.5f; // Rate for extending the grapple - Corvax Frontier

public override void Initialize()
{
Expand All @@ -58,7 +60,6 @@ private void OnGrapplingShot(EntityUid uid, GrapplingGunComponent component, ref
{
if (!HasComp<GrapplingProjectileComponent>(shotUid))
continue;

//todo: this doesn't actually support multigrapple
// At least show the visuals.
component.Projectile = shotUid.Value;
Expand Down Expand Up @@ -132,7 +133,7 @@ private void OnGunActivate(EntityUid uid, GrapplingGunComponent component, Activ

component.Projectile = null;
SetReeling(uid, component, false, args.User);
_gun.ChangeBasicEntityAmmoCount(uid, 1);
_gun.ChangeBasicEntityAmmoCount(uid, 1);

args.Handled = true;
}
Expand Down Expand Up @@ -186,8 +187,20 @@ public override void Update(float frameTime)
continue;
}

// TODO: This should be on engine.
distance.MaxLength = MathF.Max(distance.MinLength, distance.MaxLength - ReelRate * frameTime);
// Corvax Frontier start
var localTransform = Transform(uid); // Use the transform of the entity holding the grappling gun
var hookTransform = Transform(joint.BodyBUid);
var distanceBetween = (localTransform.Coordinates.Position - hookTransform.Coordinates.Position).Length();

if (grappling.Reeling)
{
distance.MaxLength = MathF.Max(distance.MinLength, distance.MaxLength - ReelRate * frameTime);
}
else
{
distance.MaxLength = MathF.Min(MaxGrappleDistance, distance.MaxLength + ExtendRate * frameTime);
}
// Corvax Frontier end
distance.Length = MathF.Min(distance.MaxLength, distance.Length);

_physics.WakeBody(joint.BodyAUid);
Expand All @@ -214,7 +227,7 @@ private void OnGrappleCollide(EntityUid uid, GrapplingProjectileComponent compon

var jointComp = EnsureComp<JointComponent>(uid);
var joint = _joints.CreateDistanceJoint(uid, args.Weapon, anchorA: new Vector2(0f, 0.5f), id: GrapplingJoint);
joint.MaxLength = joint.Length + 0.2f;
joint.MaxLength = MaxGrappleDistance; // Set the initial maximum distance to the defined maximum - Corvax Frontier
joint.Stiffness = 1f;
joint.MinLength = 0.35f;
// Setting velocity directly for mob movement fucks this so need to make them aware of it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ public sealed partial class GrapplingGunComponent : Component
new SpriteSpecifier.Rsi(new ResPath("Objects/Weapons/Guns/Launchers/grappling_gun.rsi"), "rope");

public EntityUid? Stream;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@
hard: false
mask:
- Impassable
- HighImpassable
- BulletImpassable # was HighImpassable
- type: GrapplingProjectile

# Frontier projectiles
Expand Down
Loading