From 39a42559ac7364ac519312505b4135f8cc053923 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Thu, 15 Jun 2023 20:52:49 -0400 Subject: [PATCH] Ice anomaly buff (anti-box maneuvers) (#17293) --- .../Components/ProjectileAnomalyComponent.cs | 28 ++++++------ .../Effects/ProjectileAnomalySystem.cs | 44 +++++++++++-------- .../Weapons/Guns/Projectiles/magic.yml | 2 +- .../Structures/Specific/anomalies.yml | 6 +-- 4 files changed, 44 insertions(+), 36 deletions(-) diff --git a/Content.Server/Anomaly/Components/ProjectileAnomalyComponent.cs b/Content.Server/Anomaly/Components/ProjectileAnomalyComponent.cs index 60354e6915..af395fd817 100644 --- a/Content.Server/Anomaly/Components/ProjectileAnomalyComponent.cs +++ b/Content.Server/Anomaly/Components/ProjectileAnomalyComponent.cs @@ -6,33 +6,33 @@ namespace Content.Server.Anomaly.Components; [RegisterComponent] public sealed class ProjectileAnomalyComponent : Component { - /// + /// /// The prototype of the projectile that will be shot when the anomaly pulses /// - [DataField("projectilePrototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer))] + [DataField("projectilePrototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer)), ViewVariables(VVAccess.ReadWrite)] public string ProjectilePrototype = default!; /// - /// The MAXIMUM speed can travel + /// The speed can travel /// - [DataField("maxProjectileSpeed")] - public float MaxProjectileSpeed = 30f; + [DataField("projectileSpeed"), ViewVariables(VVAccess.ReadWrite)] + public float ProjectileSpeed = 30f; + + /// + /// The minimum number of projectiles shot per pulse + /// + [DataField("minProjectiles"), ViewVariables(VVAccess.ReadWrite)] + public int MinProjectiles = 2; /// /// The MAXIMUM number of projectiles shot per pulse /// - [DataField("maxProjectiles")] - public int MaxProjectiles = 5; + [DataField("maxProjectiles"), ViewVariables(VVAccess.ReadWrite)] + public int MaxProjectiles = 9; /// /// The MAXIMUM range for targeting entities /// - [DataField("projectileRange")] + [DataField("projectileRange"), ViewVariables(VVAccess.ReadWrite)] public float ProjectileRange = 50f; - - /// - /// Chance that a non sentient entity will be targeted, value must be between 0.0-1.0 - /// - [DataField("targetNonSentientChance")] - public float TargetNonSentientChance = 0.5f; } diff --git a/Content.Server/Anomaly/Effects/ProjectileAnomalySystem.cs b/Content.Server/Anomaly/Effects/ProjectileAnomalySystem.cs index 18454dfde9..8b03c425b8 100644 --- a/Content.Server/Anomaly/Effects/ProjectileAnomalySystem.cs +++ b/Content.Server/Anomaly/Effects/ProjectileAnomalySystem.cs @@ -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(); + var projectileCount = (int) MathF.Round(MathHelper.Lerp(component.MinProjectiles, component.MaxProjectiles, severity)); + var xformQuery = GetEntityQuery(); + var mobQuery = GetEntityQuery(); + 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(); + 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); } } diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/magic.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/magic.yml index e1628c3a36..06479d26ae 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/magic.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/magic.yml @@ -139,7 +139,7 @@ types: Piercing: 20 Cold: 20 - Structural: 40 + Structural: 50 - type: entity parent: ProjectilePolyboltBase diff --git a/Resources/Prototypes/Entities/Structures/Specific/anomalies.yml b/Resources/Prototypes/Entities/Structures/Specific/anomalies.yml index 6c0e780757..93b65691d7 100644 --- a/Resources/Prototypes/Entities/Structures/Specific/anomalies.yml +++ b/Resources/Prototypes/Entities/Structures/Specific/anomalies.yml @@ -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