Skip to content

Commit

Permalink
better gun and wielded checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Fansana committed Oct 28, 2024
1 parent ec2d7a3 commit 1eaaa50
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions Content.Client/Weapons/Melee/MeleeWeaponSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Wieldable.Components;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Input;
Expand Down Expand Up @@ -94,11 +95,27 @@ public override void Update(float frameTime)
// it's kinda tricky.
// I think as long as we make secondaries their own component it's probably fine
// as long as guncomp has an alt-use key then it shouldn't be too much of a PITA to deal with.
if (TryComp<GunComponent>(weaponUid, out var gun) && gun.UseKey)
{
return;
//if (TryComp<GunComponent>(weaponUid, out var gun) && gun.UseKey)
//{
// return;
//}
// Floof changes from frontier
bool gunBoundToUse = false;
bool gunBoundToAlt = false;

if (TryComp<GunComponent>(weaponUid, out var gun)) {
gunBoundToUse = gun.UseKey;
gunBoundToAlt = !gun.UseKey; //Bound to alt-use when false

// If ranged mode only works when wielded, do not block melee attacks when unwielded
// (e.g. crusher & crusher glaive)
if (TryComp<GunRequiresWieldComponent>(weaponUid, out var _) &&
TryComp<WieldableComponent>(weaponUid, out var wield)) {
gunBoundToUse &= wield.Wielded;
gunBoundToAlt &= wield.Wielded;
}
}

// End Floof changes
var mousePos = _eyeManager.PixelToMap(_inputManager.MouseScreenPosition);

if (mousePos.MapId == MapId.Nullspace)
Expand All @@ -118,7 +135,7 @@ public override void Update(float frameTime)
}

// Heavy attack.
if (altDown == BoundKeyState.Down)
if (altDown == BoundKeyState.Down && !gunBoundToAlt) //Floof: add !gunBoundToAlt condition
{
// If it's an unarmed attack then do a disarm
if (weapon.AltDisarm && weaponUid == entity)
Expand All @@ -139,7 +156,7 @@ public override void Update(float frameTime)
}

// Light attack
if (useDown == BoundKeyState.Down)
if (useDown == BoundKeyState.Down && !gunBoundToUse) //Floof: add !gunBoundToAlt condition
{
var attackerPos = Transform(entity).MapPosition;

Expand Down

0 comments on commit 1eaaa50

Please sign in to comment.