Turrets and grenades can hit prone people [port] (#2910)
* ranged ai targets crawling people properly (cherry picked from commit 8f64627c9e35b3c873a7825f25b52319ff8c8e25) * ranged ai targets crawling people properly (cherry picked from commit 8f64627c9e35b3c873a7825f25b52319ff8c8e25) * projectile grenades hit crawling/downed people (cherry picked from commit 24c3737ae83ab399add28162a65d528d44f73ea9) * change * impstation to imp * remove extra method ops --------- Co-authored-by: Darkmajia <darkwindleaf@hotmail.co.uk>
This commit is contained in:
parent
dd283b8f20
commit
61af74c40e
|
|
@ -1,5 +1,6 @@
|
|||
using Content.Server.Explosion.Components;
|
||||
using Content.Server.Weapons.Ranged.Systems;
|
||||
using Content.Shared.Weapons.Ranged.Components; // Imp
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
|
|
@ -77,6 +78,7 @@ public sealed class ProjectileGrenadeSystem : EntitySystem
|
|||
// slightly uneven, doesn't really change much, but it looks better
|
||||
var direction = angle.ToVec().Normalized();
|
||||
var velocity = _random.NextVector2(component.MinVelocity, component.MaxVelocity);
|
||||
EnsureComp<TargetedProjectileComponent>(contentUid); // imp - ensure projectile is a TargetedProjectile with no target to hit crawling players
|
||||
_gun.ShootProjectile(contentUid, direction, velocity, uid, null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,6 +202,7 @@ public sealed partial class NPCCombatSystem
|
|||
return;
|
||||
}
|
||||
|
||||
_gun.SetTarget(gun, comp.Target); // Imp
|
||||
_gun.AttemptShoot(uid, gunUid, gun, targetCordinates);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,12 @@ public sealed class RequireProjectileTargetSystem : EntitySystem
|
|||
return;
|
||||
|
||||
var other = args.OtherEntity;
|
||||
if (TryComp(other, out ProjectileComponent? projectile) &&
|
||||
CompOrNull<TargetedProjectileComponent>(other)?.Target != ent)
|
||||
|
||||
if (TryComp(other, out TargetedProjectileComponent? targeted) && // Imp
|
||||
(targeted.Target == null || targeted.Target == ent))
|
||||
return;
|
||||
|
||||
if (TryComp(other, out ProjectileComponent? projectile))
|
||||
{
|
||||
// Prevents shooting out of while inside of crates
|
||||
var shooter = projectile.Shooter;
|
||||
|
|
|
|||
|
|
@ -8,5 +8,5 @@ namespace Content.Shared.Weapons.Ranged.Components;
|
|||
public sealed partial class TargetedProjectileComponent : Component
|
||||
{
|
||||
[DataField, AutoNetworkedField]
|
||||
public EntityUid Target;
|
||||
public EntityUid? Target; // Imp
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,6 +207,14 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||
EntityManager.DirtyField(uid, gun, nameof(GunComponent.ShotCounter));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the targeted entity of the gun. Should be called before attempting to shoot to avoid shooting over the target.
|
||||
/// </summary>
|
||||
public void SetTarget(GunComponent gun, EntityUid target) // Imp
|
||||
{
|
||||
gun.Target = target;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to shoot at the target coordinates. Resets the shot counter after every shot.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue