diff --git a/Content.Server/DeltaV/Lamiae/LamiaSystem.cs b/Content.Server/DeltaV/Lamiae/LamiaSystem.cs index 29ddfe23809..5a413e7bb29 100644 --- a/Content.Server/DeltaV/Lamiae/LamiaSystem.cs +++ b/Content.Server/DeltaV/Lamiae/LamiaSystem.cs @@ -1,9 +1,3 @@ -/* -* Delta-V - This file is licensed under AGPLv3 -* Copyright (c) 2024 Delta-V Contributors -* See AGPLv3.txt for details. -*/ - using Robust.Shared.Physics; using Content.Shared.Damage; using Content.Shared.Explosion; @@ -14,7 +8,6 @@ using Content.Shared.Inventory.Events; using Content.Shared.Tag; using Content.Shared.Teleportation.Components; -using Content.Shared.Standing; using Content.Shared.Storage.Components; using Robust.Shared.Containers; using Robust.Shared.Map; @@ -22,6 +15,10 @@ using Robust.Shared.Physics.Components; using System.Numerics; using Content.Shared.DeltaV.Lamiae; +using Robust.Shared.Physics.Events; +using Content.Shared.Projectiles; +using Content.Shared.Weapons.Ranged.Events; +using System.Linq; namespace Content.Server.DeltaV.Lamiae { @@ -32,7 +29,6 @@ public sealed partial class LamiaSystem : EntitySystem [Dependency] private readonly DamageableSystem _damageableSystem = default!; [Dependency] private readonly TagSystem _tagSystem = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; - [Dependency] private readonly StandingStateSystem _standing = default!; [ValidatePrototypeId] private const string LamiaHardsuitTag = "AllowLamiaHardsuit"; @@ -64,7 +60,7 @@ public override void Update(float frameTime) var revoluteJoint = _jointSystem.CreateWeldJoint(attachedUid, segmentUid, id: "Segment" + segment.segment.SegmentNumber + segment.segment.Lamia); revoluteJoint.CollideConnected = false; } - if (segment.segment.SegmentNumber < segment.segment.MaxSegments) + if (segment.segment.SegmentNumber <= segment.segment.MaxSegments) Transform(segmentUid).Coordinates = Transform(attachedUid).Coordinates.Offset(new Vector2(0, segment.segment.OffsetSwitching)); else Transform(segmentUid).Coordinates = Transform(attachedUid).Coordinates.Offset(new Vector2(0, segment.segment.OffsetSwitching)); @@ -82,6 +78,7 @@ public override void Initialize() SubscribeLocalEvent(OnShutdown); SubscribeLocalEvent(OnJointRemoved); SubscribeLocalEvent(OnRemovedFromContainer); + SubscribeLocalEvent(OnShootHitscan); SubscribeLocalEvent(OnSegmentSpawned); SubscribeLocalEvent(HandleDamageTransfer); SubscribeLocalEvent(HandleSegmentDamage); @@ -89,8 +86,8 @@ public override void Initialize() SubscribeLocalEvent(OnSegmentStorageInsertAttempt); SubscribeLocalEvent(OnDidEquipEvent); SubscribeLocalEvent(OnDidUnequipEvent); - SubscribeLocalEvent(TailCantStand); SubscribeLocalEvent(OnSnekBoom); + SubscribeLocalEvent(PreventShootSelf); } /// @@ -104,8 +101,6 @@ public override void Initialize() private void OnSegmentSpawned(EntityUid uid, LamiaSegmentComponent component, SegmentSpawnedEvent args) { component.Lamia = args.Lamia; - if (component.BulletPassover == true) - _standing.Down(uid, false); if (!TryComp(uid, out var species)) return; if (!TryComp(args.Lamia, out var humanoid)) return; @@ -127,7 +122,7 @@ private void OnSegmentSpawned(EntityUid uid, LamiaSegmentComponent component, Se private void OnInit(EntityUid uid, LamiaComponent component, ComponentInit args) { - Math.Clamp(component.NumberOfSegments, 2, 30); + Math.Clamp(component.NumberOfSegments, 2, 18); Math.Clamp(component.TaperOffset, 1, component.NumberOfSegments - 1); SpawnSegments(uid, component); } @@ -147,8 +142,6 @@ private void OnJointRemoved(EntityUid uid, LamiaComponent component, JointRemove if (!component.Segments.Contains(args.OtherEntity)) return; - if (HasComp(uid)) return; - foreach (var segment in component.Segments) QueueDel(segment); @@ -179,17 +172,11 @@ private void HandleDamageTransfer(EntityUid uid, LamiaSegmentComponent component _damageableSystem.TryChangeDamage(component.Lamia, args.DamageDelta); } - private void TailCantStand(EntityUid uid, LamiaSegmentComponent component, StandAttemptEvent args) - { - if (component.BulletPassover == true) - args.Cancel(); - } - public void SpawnSegments(EntityUid uid, LamiaComponent component) { int i = 1; var addTo = uid; - while (i < component.NumberOfSegments + 1) + while (i <= component.NumberOfSegments + 1) { var segment = AddSegment(addTo, uid, component, i); addTo = segment; @@ -197,24 +184,22 @@ public void SpawnSegments(EntityUid uid, LamiaComponent component) } } - private EntityUid AddSegment(EntityUid uid, EntityUid lamia, LamiaComponent lamiaComponent, int segmentNumber) + private EntityUid AddSegment(EntityUid segmentuid, EntityUid parentuid, LamiaComponent lamiaComponent, int segmentNumber) { - EnsureComp(uid, out var segmentComponent); - segmentComponent.MaxSegments = lamiaComponent.NumberOfSegments; - segmentComponent.BulletPassover = lamiaComponent.BulletPassover; - segmentComponent.Lamia = lamia; - segmentComponent.AttachedToUid = uid; + LamiaSegmentComponent segmentComponent = new(); + segmentComponent.Lamia = parentuid; + segmentComponent.AttachedToUid = segmentuid; segmentComponent.DamageModifierConstant = lamiaComponent.NumberOfSegments * lamiaComponent.DamageModifierOffset; - float taperConstant = lamiaComponent.NumberOfSegments - lamiaComponent.TaperOffset; float damageModifyCoefficient = segmentComponent.DamageModifierConstant / lamiaComponent.NumberOfSegments; segmentComponent.DamageModifyFactor = segmentComponent.DamageModifierConstant * damageModifyCoefficient; segmentComponent.ExplosiveModifyFactor = 1 / segmentComponent.DamageModifyFactor / (lamiaComponent.NumberOfSegments * lamiaComponent.ExplosiveModifierOffset); + float taperConstant = lamiaComponent.NumberOfSegments - lamiaComponent.TaperOffset; EntityUid segment; if (segmentNumber == 1) - segment = EntityManager.SpawnEntity(lamiaComponent.InitialSegmentId, Transform(uid).Coordinates); + segment = EntityManager.SpawnEntity(lamiaComponent.InitialSegmentId, Transform(segmentuid).Coordinates); else - segment = EntityManager.SpawnEntity(lamiaComponent.SegmentId, Transform(uid).Coordinates); + segment = EntityManager.SpawnEntity(lamiaComponent.SegmentId, Transform(segmentuid).Coordinates); if (segmentNumber >= taperConstant && lamiaComponent.UseTaperSystem == true) { segmentComponent.OffsetSwitching = lamiaComponent.StaticOffset * MathF.Pow(lamiaComponent.OffsetConstant, segmentNumber - taperConstant); @@ -230,10 +215,12 @@ private EntityUid AddSegment(EntityUid uid, EntityUid lamia, LamiaComponent lami segmentComponent.OffsetSwitching *= -1; } + segmentComponent.Owner = segment; segmentComponent.SegmentNumber = segmentNumber; - - _segments.Enqueue((segmentComponent, lamia)); - lamiaComponent.Segments.Add(uid); + EntityManager.AddComponent(segment, segmentComponent, true); + EnsureComp(segment); + _segments.Enqueue((segmentComponent, parentuid)); + lamiaComponent.Segments.Add(segment); return segment; } @@ -278,5 +265,28 @@ private void OnDidUnequipEvent(EntityUid equipee, LamiaComponent component, DidU } } } + + private void PreventShootSelf(EntityUid uid, LamiaSegmentComponent component, ref PreventCollideEvent args) + { + if (!TryComp(args.OtherEntity, out var projectileComponent)) return; + + if (projectileComponent.Shooter == component.Lamia) + { + args.Cancelled = true; + } + } + + private void OnShootHitscan(EntityUid uid, LamiaComponent component, ref HitScanAfterRayCastEvent args) + { + if (args.RayCastResults == null) return; + + var entityList = new List(); + foreach (var entity in args.RayCastResults) + { + if (!component.Segments.Contains(entity.HitEntity)) + entityList.Add(entity); + } + args.RayCastResults = entityList; + } } } diff --git a/Content.Server/Teleportation/PortalSystem.cs b/Content.Server/Teleportation/PortalSystem.cs index a328573fc9c..27fec274351 100644 --- a/Content.Server/Teleportation/PortalSystem.cs +++ b/Content.Server/Teleportation/PortalSystem.cs @@ -1,9 +1,7 @@ -using Content.Server.DeltaV.Lamiae; //DeltaV using Content.Shared.Administration.Logs; using Content.Shared.Database; using Content.Shared.Ghost; using Content.Shared.Mind.Components; -using Content.Shared.DeltaV.Lamiae; //DeltaV using Content.Shared.Teleportation.Systems; using Robust.Shared.Map; @@ -12,7 +10,6 @@ namespace Content.Server.Teleportation; public sealed class PortalSystem : SharedPortalSystem { [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; - [Dependency] private readonly LamiaSystem _lamia = default!; //DeltaV // TODO Move to shared protected override void LogTeleport(EntityUid portal, EntityUid subject, EntityCoordinates source, @@ -20,18 +17,5 @@ protected override void LogTeleport(EntityUid portal, EntityUid subject, EntityC { if (HasComp(subject) && !HasComp(subject)) _adminLogger.Add(LogType.Teleport, LogImpact.Low, $"{ToPrettyString(subject):player} teleported via {ToPrettyString(portal)} from {source} to {target}"); - - //Start DeltaV Code, stops Lamia from crashing because they can't take their tail through a portal - if (TryComp(subject, out var lamia)) - { - foreach (var segment in lamia.Segments) - { - QueueDel(segment); - } - lamia.Segments.Clear(); - _lamia.SpawnSegments(subject, lamia); - } - //End DeltaV Code } - } diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs index b8f8f122111..067c114b259 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs @@ -203,7 +203,13 @@ public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid? if (!rayCastResults.Any()) break; - var result = rayCastResults[0]; + var raycastEvent = new HitScanAfterRayCastEvent(rayCastResults); + RaiseLocalEvent(lastUser, ref raycastEvent); + + if (raycastEvent.RayCastResults == null) + break; + + var result = raycastEvent.RayCastResults[0]; var hit = result.HitEntity; lastHit = hit; diff --git a/Content.Shared/DeltaV/Lamiae/LamiaComponent.cs b/Content.Shared/DeltaV/Lamiae/LamiaComponent.cs index 163c31df594..bc70724404a 100644 --- a/Content.Shared/DeltaV/Lamiae/LamiaComponent.cs +++ b/Content.Shared/DeltaV/Lamiae/LamiaComponent.cs @@ -15,6 +15,7 @@ public sealed partial class LamiaComponent : Component /// /// A list of each UID attached to the Lamia, in order of spawn /// + [DataField("segments")] public List Segments = new(); /// diff --git a/Content.Shared/DeltaV/Lamiae/LamiaSegmentComponent.cs b/Content.Shared/DeltaV/Lamiae/LamiaSegmentComponent.cs index 82de76ca1a9..37d21ae6f6b 100644 --- a/Content.Shared/DeltaV/Lamiae/LamiaSegmentComponent.cs +++ b/Content.Shared/DeltaV/Lamiae/LamiaSegmentComponent.cs @@ -15,15 +15,17 @@ namespace Content.Shared.DeltaV.Lamiae [NetworkedComponent] public sealed partial class LamiaSegmentComponent : Component { + [DataField("AttachedToUid")] public EntityUid AttachedToUid = default!; public float DamageModifyFactor = default!; public float OffsetSwitching = default!; public float ScaleFactor = default!; + [DataField("DamageModifierCoefficient")] public float DamageModifierCoefficient = default!; public float ExplosiveModifyFactor = default!; public float OffsetConstant = default!; + [DataField("Lamia")] public EntityUid Lamia = default!; - public bool BulletPassover = default!; public int MaxSegments = default!; public int SegmentNumber = default!; public float DamageModifierConstant = default!; diff --git a/Content.Shared/Teleportation/Components/PortalExemptComponent.cs b/Content.Shared/Teleportation/Components/PortalExemptComponent.cs new file mode 100644 index 00000000000..28043808e09 --- /dev/null +++ b/Content.Shared/Teleportation/Components/PortalExemptComponent.cs @@ -0,0 +1,8 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.Teleportation.Components; + +[RegisterComponent, NetworkedComponent] +public sealed partial class PortalExemptComponent : Component +{ +} diff --git a/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs b/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs index 247ac93c219..6d6d971bd94 100644 --- a/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs +++ b/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs @@ -1,6 +1,5 @@ using System.Linq; using Content.Shared.Ghost; -using Content.Shared.DeltaV.Lamiae; //DeltaV using Content.Shared.Popups; using Content.Shared.Projectiles; using Content.Shared.Pulling; @@ -84,6 +83,9 @@ private bool ShouldCollide(string ourId, string otherId, Fixture our, Fixture ot private void OnCollide(EntityUid uid, PortalComponent component, ref StartCollideEvent args) { + if (HasComp(args.OtherEntity)) + return; + if (!ShouldCollide(args.OurFixtureId, args.OtherFixtureId, args.OurFixture, args.OtherFixture)) return; @@ -105,13 +107,6 @@ private void OnCollide(EntityUid uid, PortalComponent component, ref StartCollid _pulling.TryStopPull(subjectPulling); } - //Start DeltaV Code: Prevent Lamia Segments from entering portals - if (HasComp(subject)) - { - return; - } - //End DeltaV Code - // if they came from another portal, just return and wait for them to exit the portal if (HasComp(subject)) { diff --git a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs index 6a5127f2c95..c9160ffe692 100644 --- a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs +++ b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs @@ -566,7 +566,7 @@ private bool DoHeavyAttack(EntityUid user, HeavyAttackEvent ev, EntityUid meleeU Audio.PlayPredicted(component.SwingSound, meleeUid, user); return true; } - + // Naughty input if (entities.Count > MaxTargets) { diff --git a/Content.Shared/Weapons/Ranged/Events/HitScanAfterRayCastEvent.cs b/Content.Shared/Weapons/Ranged/Events/HitScanAfterRayCastEvent.cs new file mode 100644 index 00000000000..99bfd1eabc0 --- /dev/null +++ b/Content.Shared/Weapons/Ranged/Events/HitScanAfterRayCastEvent.cs @@ -0,0 +1,17 @@ +using Robust.Shared.Physics; + +namespace Content.Shared.Weapons.Ranged.Events; + +/// +/// Raised after an entity fires a hitscan weapon, but before the list is truncated to the first target. Necessary for Entities that need to prevent friendly fire +/// +[ByRefEvent] +public struct HitScanAfterRayCastEvent +{ + public List? RayCastResults; + + public HitScanAfterRayCastEvent(List? rayCastResults) + { + RayCastResults = rayCastResults; + } +} diff --git a/Resources/Prototypes/DeltaV/Entities/Mobs/Species/lamia.yml b/Resources/Prototypes/DeltaV/Entities/Mobs/Species/lamia.yml index e47bdb1e482..d7cb856e299 100644 --- a/Resources/Prototypes/DeltaV/Entities/Mobs/Species/lamia.yml +++ b/Resources/Prototypes/DeltaV/Entities/Mobs/Species/lamia.yml @@ -138,13 +138,13 @@ 0: Alive 200: Critical #these values aren't final' 300: Dead #these values aren't final' - - type: SlowOnDamage + - type: SlowOnDamage speedModifierThresholds: #these values aren't final, adjust accordingly with thresholds above' 60: 0.9 80: 0.8 100: 0.7 120: 0.6 - 140: 0.5 + 140: 0.5 - type: FireVisuals sprite: Mobs/Effects/onfire.rsi normalState: Generic_mob_burning @@ -195,7 +195,7 @@ layer: - MobLayer - type: Lamia - numberOfSegments: 30 + numberOfSegments: 18 - type: Speech speechSounds: Alto - type: Vocal