Ice anomaly buff (anti-box maneuvers) (#17293)
This commit is contained in:
@@ -6,33 +6,33 @@ namespace Content.Server.Anomaly.Components;
|
||||
[RegisterComponent]
|
||||
public sealed class ProjectileAnomalyComponent : Component
|
||||
{
|
||||
/// <sumarry>
|
||||
/// <summary>
|
||||
/// The prototype of the projectile that will be shot when the anomaly pulses
|
||||
/// </summary>
|
||||
[DataField("projectilePrototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
[DataField("projectilePrototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>)), ViewVariables(VVAccess.ReadWrite)]
|
||||
public string ProjectilePrototype = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The MAXIMUM speed <see cref="ProjectilePrototype"/> can travel
|
||||
/// The speed <see cref="ProjectilePrototype"/> can travel
|
||||
/// </summary>
|
||||
[DataField("maxProjectileSpeed")]
|
||||
public float MaxProjectileSpeed = 30f;
|
||||
[DataField("projectileSpeed"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public float ProjectileSpeed = 30f;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum number of projectiles shot per pulse
|
||||
/// </summary>
|
||||
[DataField("minProjectiles"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public int MinProjectiles = 2;
|
||||
|
||||
/// <summary>
|
||||
/// The MAXIMUM number of projectiles shot per pulse
|
||||
/// </summary>
|
||||
[DataField("maxProjectiles")]
|
||||
public int MaxProjectiles = 5;
|
||||
[DataField("maxProjectiles"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public int MaxProjectiles = 9;
|
||||
|
||||
/// <summary>
|
||||
/// The MAXIMUM range for targeting entities
|
||||
/// </summary>
|
||||
[DataField("projectileRange")]
|
||||
[DataField("projectileRange"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public float ProjectileRange = 50f;
|
||||
|
||||
/// <summary>
|
||||
/// Chance that a non sentient entity will be targeted, value must be between 0.0-1.0
|
||||
/// </summary>
|
||||
[DataField("targetNonSentientChance")]
|
||||
public float TargetNonSentientChance = 0.5f;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Anomaly.Components;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.Weapons.Ranged.Systems;
|
||||
using Content.Shared.Anomaly.Components;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Projectiles;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Anomaly.Effects;
|
||||
@@ -38,29 +40,36 @@ public sealed class ProjectileAnomalySystem : EntitySystem
|
||||
|
||||
private void ShootProjectilesAtEntities(EntityUid uid, ProjectileAnomalyComponent component, float severity)
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
var projectilesShot = 0;
|
||||
var range = component.ProjectileRange * severity;
|
||||
var mobQuery = GetEntityQuery<MindComponent>();
|
||||
var projectileCount = (int) MathF.Round(MathHelper.Lerp(component.MinProjectiles, component.MaxProjectiles, severity));
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
var mobQuery = GetEntityQuery<MobStateComponent>();
|
||||
var xform = xformQuery.GetComponent(uid);
|
||||
|
||||
foreach (var entity in _lookup.GetEntitiesInRange(uid, range, LookupFlags.Dynamic))
|
||||
var inRange = _lookup.GetEntitiesInRange(uid, component.ProjectileRange * severity, LookupFlags.Dynamic).ToList();
|
||||
_random.Shuffle(inRange);
|
||||
var priority = new List<EntityUid>();
|
||||
foreach (var entity in inRange)
|
||||
{
|
||||
if (projectilesShot >= component.MaxProjectiles * severity)
|
||||
return;
|
||||
if (mobQuery.HasComponent(entity))
|
||||
priority.Add(entity);
|
||||
}
|
||||
|
||||
// Sentient entities are more likely to be shot at than non sentient
|
||||
if (!mobQuery.HasComponent(entity) && !_random.Prob(component.TargetNonSentientChance))
|
||||
continue;
|
||||
Logger.Debug($"shots: {projectileCount}");
|
||||
while (projectileCount > 0)
|
||||
{
|
||||
Logger.Debug($"{projectileCount}");
|
||||
var target = priority.Any()
|
||||
? _random.PickAndTake(priority)
|
||||
: _random.Pick(inRange);
|
||||
|
||||
var targetCoords = Transform(entity).Coordinates.Offset(_random.NextVector2(-1, 1));
|
||||
var targetCoords = xformQuery.GetComponent(target).Coordinates.Offset(_random.NextVector2(0.5f));
|
||||
|
||||
ShootProjectile(
|
||||
uid, component,
|
||||
xform.Coordinates,
|
||||
targetCoords,
|
||||
severity
|
||||
);
|
||||
projectilesShot++;
|
||||
severity);
|
||||
projectileCount--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,8 +78,7 @@ public sealed class ProjectileAnomalySystem : EntitySystem
|
||||
ProjectileAnomalyComponent component,
|
||||
EntityCoordinates coords,
|
||||
EntityCoordinates targetCoords,
|
||||
float severity
|
||||
)
|
||||
float severity)
|
||||
{
|
||||
var mapPos = coords.ToMap(EntityManager, _xform);
|
||||
|
||||
@@ -86,6 +94,6 @@ public sealed class ProjectileAnomalySystem : EntitySystem
|
||||
|
||||
comp.Damage *= severity;
|
||||
|
||||
_gunSystem.ShootProjectile(ent, direction, Vector2.Zero, uid, uid, component.MaxProjectileSpeed * severity);
|
||||
_gunSystem.ShootProjectile(ent, direction, Vector2.Zero, uid, uid, component.ProjectileSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@
|
||||
types:
|
||||
Piercing: 20
|
||||
Cold: 20
|
||||
Structural: 40
|
||||
Structural: 50
|
||||
|
||||
- type: entity
|
||||
parent: ProjectilePolyboltBase
|
||||
|
||||
@@ -215,9 +215,9 @@
|
||||
Cold: 10
|
||||
- type: ExplosionAnomaly
|
||||
supercriticalExplosion: Cryo
|
||||
explosionTotalIntensity: 1000
|
||||
explosionDropoff: 1
|
||||
explosionMaxTileIntensity: 10
|
||||
explosionTotalIntensity: 300
|
||||
explosionDropoff: 2
|
||||
explosionMaxTileIntensity: 20
|
||||
- type: ProjectileAnomaly
|
||||
projectilePrototype: ProjectileIcicle
|
||||
targetNonSentientChance: 0.1
|
||||
|
||||
Reference in New Issue
Block a user