Xeno spitter fixes (#18573)
* Xeno spitter fixes - Require hands for pickup compounds - Ranged combat can force movement to ignore LOS checks if ranged wants better LOS. * Also spirates IDK how this worked before but TryGetGun shouldn't care about combatmode. * 1 more
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Numerics;
|
|||||||
using Content.Client.Items;
|
using Content.Client.Items;
|
||||||
using Content.Client.Weapons.Ranged.Components;
|
using Content.Client.Weapons.Ranged.Components;
|
||||||
using Content.Shared.Camera;
|
using Content.Shared.Camera;
|
||||||
|
using Content.Shared.CombatMode;
|
||||||
using Content.Shared.Spawners.Components;
|
using Content.Shared.Spawners.Components;
|
||||||
using Content.Shared.Weapons.Ranged;
|
using Content.Shared.Weapons.Ranged;
|
||||||
using Content.Shared.Weapons.Ranged.Components;
|
using Content.Shared.Weapons.Ranged.Components;
|
||||||
@@ -126,7 +127,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
|
|
||||||
var entityNull = _player.LocalPlayer?.ControlledEntity;
|
var entityNull = _player.LocalPlayer?.ControlledEntity;
|
||||||
|
|
||||||
if (entityNull == null)
|
if (entityNull == null || !TryComp<CombatModeComponent>(entityNull, out var combat) || !combat.IsInCombatMode)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ public sealed class NPCSteeringComponent : Component
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set to true from other systems if you wish to force the NPC to move closer.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("forceMove")]
|
||||||
|
public bool ForceMove = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Next time we can change our steering direction.
|
/// Next time we can change our steering direction.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Content.Server.NPC.Components;
|
using Content.Server.NPC.Components;
|
||||||
using Content.Shared.CombatMode;
|
using Content.Shared.CombatMode;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Shared.Physics;
|
||||||
using Content.Shared.Weapons.Ranged.Components;
|
using Content.Shared.Weapons.Ranged.Components;
|
||||||
using Content.Shared.Weapons.Ranged.Events;
|
using Content.Shared.Weapons.Ranged.Events;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
@@ -132,13 +133,20 @@ public sealed partial class NPCCombatSystem
|
|||||||
if (comp.LOSAccumulator < 0f)
|
if (comp.LOSAccumulator < 0f)
|
||||||
{
|
{
|
||||||
comp.LOSAccumulator += UnoccludedCooldown;
|
comp.LOSAccumulator += UnoccludedCooldown;
|
||||||
comp.TargetInLOS = _interaction.InRangeUnobstructed(uid, comp.Target, distance + 0.1f);
|
// For consistency with NPC steering.
|
||||||
|
comp.TargetInLOS = _interaction.InRangeUnobstructed(uid, Transform(comp.Target).Coordinates, distance + 0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!comp.TargetInLOS)
|
if (!comp.TargetInLOS)
|
||||||
{
|
{
|
||||||
comp.ShootAccumulator = 0f;
|
comp.ShootAccumulator = 0f;
|
||||||
comp.Status = CombatStatus.NotInSight;
|
comp.Status = CombatStatus.NotInSight;
|
||||||
|
|
||||||
|
if (TryComp(uid, out steering))
|
||||||
|
{
|
||||||
|
steering.ForceMove = true;
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,8 +196,14 @@ public sealed partial class NPCCombatSystem
|
|||||||
targetCordinates = new EntityCoordinates(xform.MapUid!.Value, targetSpot);
|
targetCordinates = new EntityCoordinates(xform.MapUid!.Value, targetSpot);
|
||||||
}
|
}
|
||||||
|
|
||||||
_gun.AttemptShoot(uid, gunUid, gun, targetCordinates);
|
|
||||||
comp.Status = CombatStatus.Normal;
|
comp.Status = CombatStatus.Normal;
|
||||||
|
|
||||||
|
if (gun.NextFire > _timing.CurTime)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_gun.AttemptShoot(uid, gunUid, gun, targetCordinates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public sealed partial class NPCSteeringSystem
|
|||||||
|
|
||||||
// Check if we're in LOS if that's required.
|
// Check if we're in LOS if that's required.
|
||||||
// TODO: Need something uhh better not sure on the interaction between these.
|
// TODO: Need something uhh better not sure on the interaction between these.
|
||||||
if (steering.ArriveOnLineOfSight)
|
if (!steering.ForceMove && steering.ArriveOnLineOfSight)
|
||||||
{
|
{
|
||||||
// TODO: use vision range
|
// TODO: use vision range
|
||||||
inLos = _interaction.InRangeUnobstructed(uid, steering.Coordinates, 10f);
|
inLos = _interaction.InRangeUnobstructed(uid, steering.Coordinates, 10f);
|
||||||
@@ -105,6 +105,7 @@ public sealed partial class NPCSteeringSystem
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
steering.LineOfSightTimer = 0f;
|
steering.LineOfSightTimer = 0f;
|
||||||
|
steering.ForceMove = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We've arrived, nothing else matters.
|
// We've arrived, nothing else matters.
|
||||||
|
|||||||
@@ -126,8 +126,11 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
var user = args.SenderSession.AttachedEntity;
|
var user = args.SenderSession.AttachedEntity;
|
||||||
|
|
||||||
if (user == null ||
|
if (user == null ||
|
||||||
|
!_combatMode.IsInCombatMode(user) ||
|
||||||
!TryGetGun(user.Value, out var ent, out var gun))
|
!TryGetGun(user.Value, out var ent, out var gun))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ent != msg.Gun)
|
if (ent != msg.Gun)
|
||||||
return;
|
return;
|
||||||
@@ -165,9 +168,6 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
gunEntity = default;
|
gunEntity = default;
|
||||||
gunComp = null;
|
gunComp = null;
|
||||||
|
|
||||||
if (!_combatMode.IsInCombatMode(entity))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent(entity, out HandsComponent? hands) &&
|
if (EntityManager.TryGetComponent(entity, out HandsComponent? hands) &&
|
||||||
hands.ActiveHandEntity is { } held &&
|
hands.ActiveHandEntity is { } held &&
|
||||||
TryComp(held, out GunComponent? gun))
|
TryComp(held, out GunComponent? gun))
|
||||||
|
|||||||
@@ -71,6 +71,7 @@
|
|||||||
|
|
||||||
- !type:HTNPrimitiveTask
|
- !type:HTNPrimitiveTask
|
||||||
preconditions:
|
preconditions:
|
||||||
|
- !type:ActiveHandFreePrecondition
|
||||||
- !type:TargetInRangePrecondition
|
- !type:TargetInRangePrecondition
|
||||||
targetKey: Target
|
targetKey: Target
|
||||||
rangeKey: InteractRange
|
rangeKey: InteractRange
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
- !type:HTNPrimitiveTask
|
- !type:HTNPrimitiveTask
|
||||||
preconditions:
|
preconditions:
|
||||||
|
- !type:ActiveHandFreePrecondition
|
||||||
- !type:TargetInRangePrecondition
|
- !type:TargetInRangePrecondition
|
||||||
targetKey: Target
|
targetKey: Target
|
||||||
rangeKey: InteractRange
|
rangeKey: InteractRange
|
||||||
|
|||||||
Reference in New Issue
Block a user