From 38e09e6e511b793580ac82a6ddf06fdcd025fff9 Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Fri, 8 Mar 2024 23:16:24 -0600 Subject: [PATCH 01/17] Salvo options --- .../CoreSystems/Definitions/CoreDefinitions.cs | 2 ++ .../EntityComp/Controls/TerminalHelpers.cs | 13 +++++++++++-- .../EntityComp/Parts/Weapon/WeaponComp.cs | 2 ++ Data/Scripts/CoreSystems/EntityComp/PlatformInit.cs | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs b/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs index 1721c3c9..35b735a3 100644 --- a/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs +++ b/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs @@ -529,6 +529,8 @@ public struct UiDef [ProtoMember(6)] internal bool DisableStatus; [ProtoMember(7)] internal float RateOfFireMin; [ProtoMember(8)] internal bool DisableSupportingPD; + [ProtoMember(9)] internal bool ProhibitShotDelay; + [ProtoMember(10)] internal bool ProhibitBurstCount; } diff --git a/Data/Scripts/CoreSystems/EntityComp/Controls/TerminalHelpers.cs b/Data/Scripts/CoreSystems/EntityComp/Controls/TerminalHelpers.cs index bf047550..9774fd7a 100644 --- a/Data/Scripts/CoreSystems/EntityComp/Controls/TerminalHelpers.cs +++ b/Data/Scripts/CoreSystems/EntityComp/Controls/TerminalHelpers.cs @@ -80,7 +80,7 @@ internal static void AddTurretOrTrackingControls(Session session) where T : I Separator(session, "WC_sep3", IsTrue); AddWeaponBurstCountSliderRange(session, "Burst Count", Localization.GetText("TerminalBurstShotsTitle"), Localization.GetText("TerminalBurstShotsTooltip"), BlockUi.GetBurstCount, BlockUi.RequestSetBurstCount, CanBurstIsNotBomb, BlockUi.GetMinBurstCount, BlockUi.GetMaxBurstCount, true); - AddWeaponBurstDelaySliderRange(session, "Burst Delay", Localization.GetText("TerminalBurstDelayTitle"), Localization.GetText("TerminalBurstDelayTooltip"), BlockUi.GetBurstDelay, BlockUi.RequestSetBurstDelay, IsNotBomb, BlockUi.GetMinBurstDelay, BlockUi.GetMaxBurstDelay, true); + AddWeaponBurstDelaySliderRange(session, "Burst Delay", Localization.GetText("TerminalBurstDelayTitle"), Localization.GetText("TerminalBurstDelayTooltip"), BlockUi.GetBurstDelay, BlockUi.RequestSetBurstDelay, AllowShotDelay, BlockUi.GetMinBurstDelay, BlockUi.GetMaxBurstDelay, true); AddWeaponSequenceIdSliderRange(session, "Sequence Id", Localization.GetText("TerminalSequenceIdTitle"), Localization.GetText("TerminalSequenceIdTooltip"), BlockUi.GetSequenceId, BlockUi.RequestSetSequenceId, IsNotBomb, BlockUi.GetMinSequenceId, BlockUi.GetMaxSequenceId, false); AddWeaponGroupIdIdSliderRange(session, "Weapon Group Id", Localization.GetText("TerminalWeaponGroupIdTitle"), Localization.GetText("TerminalWeaponGroupIdTooltip"), BlockUi.GetWeaponGroupId, BlockUi.RequestSetWeaponGroupId, IsNotBomb, BlockUi.GetMinWeaponGroupId, BlockUi.GetMaxWeaponGroupId, true); @@ -316,7 +316,7 @@ internal static bool CanBurst(IMyTerminalBlock block) if (!valid || Session.I.PlayerId != comp.Data.Repo.Values.State.PlayerId && !comp.TakeOwnerShip()) return false; - return !comp.HasDisabledBurst; + return !comp.ProhibitBurstCount && !comp.HasDisabledBurst; } internal static bool CanBurstIsNotBomb(IMyTerminalBlock block) @@ -533,6 +533,15 @@ internal static bool IsNotBomb(IMyTerminalBlock block) return !comp.IsBomb && !comp.HasAlternateUi; } + internal static bool AllowShotDelay(IMyTerminalBlock block) + { + var comp = block?.Components?.Get() as Weapon.WeaponComponent; + var valid = comp != null && comp.Platform.State == CorePlatform.PlatformState.Ready && comp.Data?.Repo != null; + if (!valid || Session.I.PlayerId != comp.Data.Repo.Values.State.PlayerId && !comp.TakeOwnerShip()) + return false; + + return !comp.ProhibitShotDelay; + } internal static bool HasSupport(IMyTerminalBlock block) { var comp = block?.Components?.Get(); diff --git a/Data/Scripts/CoreSystems/EntityComp/Parts/Weapon/WeaponComp.cs b/Data/Scripts/CoreSystems/EntityComp/Parts/Weapon/WeaponComp.cs index 0f0ec695..f9cb8e32 100644 --- a/Data/Scripts/CoreSystems/EntityComp/Parts/Weapon/WeaponComp.cs +++ b/Data/Scripts/CoreSystems/EntityComp/Parts/Weapon/WeaponComp.cs @@ -65,6 +65,8 @@ public partial class WeaponComponent : CoreComponent internal bool HasDrone; internal bool ShootRequestDirty; internal bool DisableSupportingPD; + internal bool ProhibitShotDelay; + internal bool ProhibitBurstCount; internal WeaponComponent(MyEntity coreEntity, MyDefinitionId id) { diff --git a/Data/Scripts/CoreSystems/EntityComp/PlatformInit.cs b/Data/Scripts/CoreSystems/EntityComp/PlatformInit.cs index 02672688..4fdbe253 100644 --- a/Data/Scripts/CoreSystems/EntityComp/PlatformInit.cs +++ b/Data/Scripts/CoreSystems/EntityComp/PlatformInit.cs @@ -729,6 +729,8 @@ internal void SetupWeaponUi(Weapon w) w.Comp.HasAlternateUi = w.Comp.HasAlternateUi || w.System.AlternateUi; w.Comp.HasRofSlider = w.Comp.HasRofSlider || ui.RateOfFire; w.Comp.DisableSupportingPD = w.Comp.DisableSupportingPD || ui.DisableSupportingPD; + w.Comp.ProhibitShotDelay = w.Comp.ProhibitShotDelay || ui.ProhibitShotDelay; + w.Comp.ProhibitBurstCount = w.Comp.ProhibitBurstCount || ui.ProhibitBurstCount; w.Comp.HasDrone = w.Comp.HasDrone || w.System.HasDrone; w.BaseComp.CanOverload = w.BaseComp.CanOverload || ui.EnableOverload; w.BaseComp.HasTurret = w.BaseComp.HasTurret || w.TurretAttached; From 6461abd2e4f2359a8072b025a753e2f4b3c0bd62 Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Wed, 13 Mar 2024 20:23:30 -0500 Subject: [PATCH 02/17] Anti hydroman cheese Ignore unowned blocks messing with raycast for topent targeting --- Data/Scripts/CoreSystems/Ai/AiTargeting.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Data/Scripts/CoreSystems/Ai/AiTargeting.cs b/Data/Scripts/CoreSystems/Ai/AiTargeting.cs index 81d8afec..09a6e63f 100644 --- a/Data/Scripts/CoreSystems/Ai/AiTargeting.cs +++ b/Data/Scripts/CoreSystems/Ai/AiTargeting.cs @@ -324,7 +324,11 @@ private static bool AcquireTopMostEntity(Weapon w, ProtoWeaponOverrides overRide if (w.LastHitInfo?.HitEntity != null && (!w.System.Values.HardPoint.Other.MuzzleCheck || !w.MuzzleHitSelf())) { TargetInfo hitInfo; - if (w.LastHitInfo.HitEntity == info.Target || ai.Targets.TryGetValue((MyEntity)w.LastHitInfo.HitEntity, out hitInfo) && (hitInfo.EntInfo.Relationship == MyRelationsBetweenPlayerAndBlock.Enemies || hitInfo.EntInfo.Relationship == MyRelationsBetweenPlayerAndBlock.Neutral || hitInfo.EntInfo.Relationship == MyRelationsBetweenPlayerAndBlock.NoOwnership)) + var targMatch = w.LastHitInfo.HitEntity == info.Target; + var targOther = !targMatch && ai.Targets.TryGetValue((MyEntity)w.LastHitInfo.HitEntity, out hitInfo) && (hitInfo.EntInfo.Relationship == MyRelationsBetweenPlayerAndBlock.Enemies || hitInfo.EntInfo.Relationship == MyRelationsBetweenPlayerAndBlock.Neutral || hitInfo.EntInfo.Relationship == MyRelationsBetweenPlayerAndBlock.NoOwnership); + var targChar = !targMatch && character != null && !ai.ObstructionLookup.ContainsKey((MyEntity)w.LastHitInfo.HitEntity); + + if (targMatch || targOther || targChar) { double rayDist; Vector3D.Distance(ref weaponPos, ref targetCenter, out rayDist); From eeb716af5624b5c217e9b4ebcafe2458f1858696 Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Mon, 18 Mar 2024 11:21:21 -0500 Subject: [PATCH 03/17] Github link updates --- Data/Scripts/CoreSystems/Session/SessionSupport.cs | 2 +- Data/Scripts/CoreSystems/Support/VersionControl.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Data/Scripts/CoreSystems/Session/SessionSupport.cs b/Data/Scripts/CoreSystems/Session/SessionSupport.cs index 6f67a022..b9c6290d 100644 --- a/Data/Scripts/CoreSystems/Session/SessionSupport.cs +++ b/Data/Scripts/CoreSystems/Session/SessionSupport.cs @@ -868,7 +868,7 @@ private void ChatMessageSet(string message, ref bool sendToOthers) if (!somethingUpdated) { if (message.Length <= 3) - MyAPIGateway.Utilities.ShowNotification("HELPFUL TIPS: https://github.com/sstixrud/WeaponCore/wiki/Player-Tips\nValid WeaponCore Commands:\n'/wc advanced -- Toggle advanced UI features'\n'/wc remap -- Remap keys'\n'/wc avlimit 5' -- Hard limits visual effects (valid range: 0 - 20, 0 is unlimited)\n'/wc changehud' to enable moving/resizing of WC Hud\n'/wc setdefaults' -- Resets shield client configs to default values\n'/wc stickypainter' -- Disable Painter LoS checks\n", 10000); + MyAPIGateway.Utilities.ShowNotification("HELPFUL TIPS: https://github.com/Ash-LikeSnow/WeaponCore/wiki/Player-Tips\nValid WeaponCore Commands:\n'/wc advanced -- Toggle advanced UI features'\n'/wc remap -- Remap keys'\n'/wc avlimit 5' -- Hard limits visual effects (valid range: 0 - 20, 0 is unlimited)\n'/wc changehud' to enable moving/resizing of WC Hud\n'/wc setdefaults' -- Resets shield client configs to default values\n'/wc stickypainter' -- Disable Painter LoS checks\n", 10000); else if (message.StartsWith("/wc remap")) MyAPIGateway.Utilities.ShowNotification("'/wc remap keyboard' -- Remaps control key (default R)\n'/wc remap mouse' -- Remaps menu mouse key (default middle button)\n'/wc remap action' -- Remaps action key (default numpad0)\n'/wc remap info' -- Remaps info key (default decimal key, aka numpad period key)\n'/wc remap next' -- Remaps the Cycle Next Target key (default Page Down)\n'/wc remap prev' -- Remaps the Cycle Previous Target key (default Page Up)\n", 10000, "White"); } diff --git a/Data/Scripts/CoreSystems/Support/VersionControl.cs b/Data/Scripts/CoreSystems/Support/VersionControl.cs index 3ea4d260..dc0d4de6 100644 --- a/Data/Scripts/CoreSystems/Support/VersionControl.cs +++ b/Data/Scripts/CoreSystems/Support/VersionControl.cs @@ -78,7 +78,7 @@ public void InitSettings() if (VersionChange) { Core.Session.PlayerStartMessage = true; - Core.Session.PlayerMessage = "You may access WeaponCore client settings with the /wc chat command\n- for helpful tips goto: https://github.com/sstixrud/WeaponCore/wiki/Player-Tips"; + Core.Session.PlayerMessage = "You may access WeaponCore client settings with the /wc chat command\n- for helpful tips goto: https://github.com/Ash-LikeSnow/WeaponCore/wiki/Player-Tips"; } } From 05ab1225e6514cf385e512fe8089d557d76ac55e Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Tue, 26 Mar 2024 00:55:45 -0500 Subject: [PATCH 04/17] Re-enable debug mode for mod dev --- Data/Scripts/CoreSystems/Session/SessionSupport.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Data/Scripts/CoreSystems/Session/SessionSupport.cs b/Data/Scripts/CoreSystems/Session/SessionSupport.cs index b9c6290d..929a9835 100644 --- a/Data/Scripts/CoreSystems/Session/SessionSupport.cs +++ b/Data/Scripts/CoreSystems/Session/SessionSupport.cs @@ -839,13 +839,9 @@ private void ChatMessageSet(string message, ref bool sendToOthers) Settings.VersionControl.UpdateClientCfgFile(); break; case "debug": - if (DebugVersion) - { - somethingUpdated = true; - DebugMod = !DebugMod; - MyAPIGateway.Utilities.ShowNotification($"Debug has been toggled: {DebugMod}", 10000); - } - + somethingUpdated = true; + DebugMod = !DebugMod; + MyAPIGateway.Utilities.ShowNotification($"Debug has been toggled: {DebugMod}", 10000); break; case "unsupportedmode": if (HandlesInput) @@ -1196,7 +1192,7 @@ public void WeaponDebug(Weapon w) private void ModChecker() { - LocalVersion = ModContext.ModId == "CoreSystems"; + LocalVersion = ModContext.ModId == "CoreSystems" || ModContext.ModId == "WeaponCore"; if (LocalVersion) { From d50d7b9c06dca0545bf54478083f1de25506a1e1 Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:15:30 -0500 Subject: [PATCH 05/17] Add prohibit cooling when off option --- .../CoreSystems/Definitions/CoreDefinitions.cs | 1 + Data/Scripts/CoreSystems/Definitions/CoreSystems.cs | 6 ++++-- .../EntityComp/Parts/Weapon/WeaponController.cs | 11 +++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs b/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs index 35b735a3..207f1143 100644 --- a/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs +++ b/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs @@ -514,6 +514,7 @@ public struct LoadingDef [ProtoMember(22)] internal int MaxReloads; [ProtoMember(23)] internal bool GoHomeToReload; [ProtoMember(24)] internal bool DropTargetUntilLoaded; + [ProtoMember(25)] internal bool ProhibitCoolingWhenOff; } diff --git a/Data/Scripts/CoreSystems/Definitions/CoreSystems.cs b/Data/Scripts/CoreSystems/Definitions/CoreSystems.cs index 6418a082..650dc0c3 100644 --- a/Data/Scripts/CoreSystems/Definitions/CoreSystems.cs +++ b/Data/Scripts/CoreSystems/Definitions/CoreSystems.cs @@ -178,6 +178,7 @@ public AmmoType(AmmoDef ammoDef, MyDefinitionId ammoDefinitionId, MyDefinitionId public readonly bool OnlySubSystems; public readonly bool ClosestFirst; public readonly bool DegRof; + public readonly bool ProhibitCoolingWhenOff; public readonly bool TrackProjectile; public readonly bool DisableSupportingPD; public readonly bool ScanTrackOnly; @@ -359,7 +360,7 @@ public WeaponSystem(WeaponStructure structure, MyStringHash partNameIdHash, MySt HasScope = !string.IsNullOrEmpty(Values.Assignments.Scope); AltScopeName = HasScope ? "subpart_" + Values.Assignments.Scope : string.Empty; TurretMovements(out AzStep, out ElStep, out MinAzimuth, out MaxAzimuth, out MinElevation, out MaxElevation, out HomeAzimuth, out HomeElevation, out TurretMovement); - Heat(out DegRof, out MaxHeat, out WepCoolDown); + Heat(out DegRof, out MaxHeat, out WepCoolDown, out ProhibitCoolingWhenOff); BarrelValues(out BarrelsPerShot, out ShotsPerBurst); BarrelsAv(out BarrelEffect1, out BarrelEffect2, out Barrel1AvTicks, out Barrel2AvTicks, out BarrelSpinRate, out HasBarrelRotation); Track(out ScanTrackOnly, out NonThreatsOnly, out TrackProjectile, out TrackGrids, out TrackCharacters, out TrackMeteors, out TrackNeutrals, out ScanNonThreats, out ScanThreats, out MaxTrackingTime, out MaxTrackingTicks, out TrackTopMostEntities); @@ -484,8 +485,9 @@ private void GetThreats(out HashSet set, out bool projectilesFirst, out boo projectilesOnly = projectilesFirst && Values.Targeting.Threats.Length == 1; } - private void Heat(out bool degRof, out int maxHeat, out float wepCoolDown) + private void Heat(out bool degRof, out int maxHeat, out float wepCoolDown, out bool coolWhenOff) { + coolWhenOff = Values.HardPoint.Loading.ProhibitCoolingWhenOff; degRof = Values.HardPoint.Loading.DegradeRof; maxHeat = Values.HardPoint.Loading.MaxHeat; wepCoolDown = Values.HardPoint.Loading.Cooldown; diff --git a/Data/Scripts/CoreSystems/EntityComp/Parts/Weapon/WeaponController.cs b/Data/Scripts/CoreSystems/EntityComp/Parts/Weapon/WeaponController.cs index 50b68be1..ca7a7fb5 100644 --- a/Data/Scripts/CoreSystems/EntityComp/Parts/Weapon/WeaponController.cs +++ b/Data/Scripts/CoreSystems/EntityComp/Parts/Weapon/WeaponController.cs @@ -259,10 +259,13 @@ internal void UpdateWeaponHeat(object o = null) { try { - var hsRateMod = HsRate + (float)Comp.HeatLoss; - Comp.CurrentHeat = Comp.CurrentHeat >= hsRateMod ? Comp.CurrentHeat - hsRateMod : 0; - PartState.Heat = PartState.Heat >= hsRateMod ? PartState.Heat - hsRateMod : 0; - Comp.HeatLoss = 0; + if (!System.ProhibitCoolingWhenOff || System.ProhibitCoolingWhenOff && Comp.Cube.IsWorking) + { + var hsRateMod = HsRate + (float)Comp.HeatLoss; + Comp.CurrentHeat = Comp.CurrentHeat >= hsRateMod ? Comp.CurrentHeat - hsRateMod : 0; + PartState.Heat = PartState.Heat >= hsRateMod ? PartState.Heat - hsRateMod : 0; + Comp.HeatLoss = 0; + } var set = PartState.Heat - LastHeat > 0.001 || PartState.Heat - LastHeat < 0.001; From 0710684b12fcc7be0daa71ec50ccc10e749807dd Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Sat, 20 Apr 2024 02:19:16 -0500 Subject: [PATCH 06/17] ObjectsHit ammo update --- Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs | 1 + Data/Scripts/CoreSystems/Session/SessionDamageMgr.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs b/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs index 207f1143..b13d4cd0 100644 --- a/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs +++ b/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs @@ -787,6 +787,7 @@ public struct ObjectsHitDef { [ProtoMember(1)] internal int MaxObjectsHit; [ProtoMember(2)] internal bool CountBlocks; + [ProtoMember(3)] internal bool SkipBlocksForAOE; } diff --git a/Data/Scripts/CoreSystems/Session/SessionDamageMgr.cs b/Data/Scripts/CoreSystems/Session/SessionDamageMgr.cs index 2c2bdf20..fa8c154a 100644 --- a/Data/Scripts/CoreSystems/Session/SessionDamageMgr.cs +++ b/Data/Scripts/CoreSystems/Session/SessionDamageMgr.cs @@ -407,7 +407,7 @@ private void DamageGrid(HitEntity hitEnt, ProInfo t) var partialShield = t.ShieldInLine && !t.ShieldBypassed && SApi.MatchEntToShieldFast(grid, true) != null; var objectsHit = t.ObjectsHit; var blockCount = hitEnt.Blocks.Count; - var countBlocksAsObjects = t.AmmoDef.ObjectsHit.CountBlocks; + var countBlocksAsObjects = t.AmmoDef.ObjectsHit.CountBlocks && !t.AmmoDef.ObjectsHit.SkipBlocksForAOE; //General damage data From 41b8f622c0c5753c716ca83fd5a55f7c57a244aa Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Sat, 20 Apr 2024 06:11:38 -0500 Subject: [PATCH 07/17] MaxAbsorb + Pooled AOE touchups --- .../CoreSystems/Session/SessionDamageMgr.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Data/Scripts/CoreSystems/Session/SessionDamageMgr.cs b/Data/Scripts/CoreSystems/Session/SessionDamageMgr.cs index fa8c154a..1ae3598f 100644 --- a/Data/Scripts/CoreSystems/Session/SessionDamageMgr.cs +++ b/Data/Scripts/CoreSystems/Session/SessionDamageMgr.cs @@ -407,7 +407,7 @@ private void DamageGrid(HitEntity hitEnt, ProInfo t) var partialShield = t.ShieldInLine && !t.ShieldBypassed && SApi.MatchEntToShieldFast(grid, true) != null; var objectsHit = t.ObjectsHit; var blockCount = hitEnt.Blocks.Count; - var countBlocksAsObjects = t.AmmoDef.ObjectsHit.CountBlocks && !t.AmmoDef.ObjectsHit.SkipBlocksForAOE; + var countBlocksAsObjects = t.AmmoDef.ObjectsHit.CountBlocks; //General damage data @@ -443,6 +443,8 @@ private void DamageGrid(HitEntity hitEnt, ProInfo t) basePool = 0; break; } + else if(hasDet && objectsHit >= maxObjects && t.AmmoDef.ObjectsHit.SkipBlocksForAOE) + basePool = 0; var aoeAbsorb = 0d; var aoeDepth = 0d; @@ -684,8 +686,6 @@ private void DamageGrid(HitEntity hitEnt, ProInfo t) basePool = 0; t.BaseDamagePool = basePool; detRequested = hasDet; - if (countBlocksAsObjects) - objectsHit++; } else if (primaryDamage) { @@ -693,10 +693,13 @@ private void DamageGrid(HitEntity hitEnt, ProInfo t) deadBlock = true; var scale = baseScale == 0d ? 0.0000001 : baseScale; basePool -= (float)(blockHp / scale); - if (countBlocksAsObjects) - objectsHit++; } + if (countBlocksAsObjects && (primaryDamage || !primaryDamage && countBlocksAsObjects && !t.AmmoDef.ObjectsHit.SkipBlocksForAOE)) + objectsHit++; + if(objectsHit >= maxObjects && primaryDamage) + detRequested = hasDet; + //AOE damage logic applied to aoeDamageFall if (!rootStep && (hasAoe || hasDet) && aoeDamage >= 0 && aoeDamageFall >= 0 && !deadBlock) { @@ -734,7 +737,7 @@ private void DamageGrid(HitEntity hitEnt, ProInfo t) //Log.Line($"Aoedmgpool {aoeDamage} scaleddmg {aoeScaledDmg}"); } } - aoeDmgTally += aoeScaledDmg; + aoeDmgTally += aoeScaledDmg > (float)blockHp ? (float)blockHp : aoeScaledDmg; scaledDamage = aoeScaledDmg; if (!aoeIsPool && scaledDamage > blockHp) @@ -839,7 +842,8 @@ private void DamageGrid(HitEntity hitEnt, ProInfo t) } else if (block.Integrity - realDmg > 0) _slimHealthClient[block] = (float)(blockHp - realDmg); } - var endCycle = (!foundAoeBlocks && basePool <= 0) || (!rootStep && (aoeDmgTally >= aoeAbsorb && aoeAbsorb != 0 || aoeDamage <= 0.5d)) || objectsHit > maxObjects; + + var endCycle = (!foundAoeBlocks && basePool <= 0) || (!rootStep && (aoeDmgTally >= aoeAbsorb && aoeAbsorb != 0 && !aoeIsPool || aoeDamage <= 0.5d)) || (!t.AmmoDef.ObjectsHit.SkipBlocksForAOE && objectsHit >= maxObjects) || t.AmmoDef.ObjectsHit.SkipBlocksForAOE && rootStep; if (showHits && primaryDamage) Log.Line($"{t.AmmoDef.AmmoRound} Primary Dmg: RootBlock {rootBlock} hit for {scaledDamage} damage of {blockHp} block HP total"); //doneskies From 11fc662a0717947fcf3f5086d4537b287515d4e9 Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Sat, 20 Apr 2024 15:44:43 -0500 Subject: [PATCH 08/17] Handwep dumbfired smart PD fix --- Data/Scripts/CoreSystems/Projectiles/ProjectileGen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/Scripts/CoreSystems/Projectiles/ProjectileGen.cs b/Data/Scripts/CoreSystems/Projectiles/ProjectileGen.cs index 840188ce..e1d985fb 100644 --- a/Data/Scripts/CoreSystems/Projectiles/ProjectileGen.cs +++ b/Data/Scripts/CoreSystems/Projectiles/ProjectileGen.cs @@ -190,7 +190,7 @@ private void SpawnFragments() var dumbAdd = false; - var notSmart = ammoDef.Trajectory.Guidance == TrajectoryDef.GuidanceType.None || overrides.Override && p.HadTarget == Projectile.HadTargetState.None; + var notSmart = ammoDef.Trajectory.Guidance == TrajectoryDef.GuidanceType.None || overrides.Override && p.HadTarget == Projectile.HadTargetState.None || info.Weapon.Comp.TypeSpecific == CoreComponent.CompTypeSpecific.Rifle && p.HadTarget == Projectile.HadTargetState.None; if (notSmart) { if (Vector3.Dot(p.Direction, info.Origin - targetAi.TopEntity.PositionComp.WorldMatrixRef.Translation) < 0) From ade9d06cd2aa868efe93456f6224b0422f6a0cde Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Fri, 26 Apr 2024 08:33:00 -0500 Subject: [PATCH 09/17] Suppress tracer variance for faction colors --- Data/Scripts/CoreSystems/AudioVisual/AvShot.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs b/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs index b1133d80..83d83663 100644 --- a/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs +++ b/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs @@ -659,8 +659,9 @@ internal void LineVariableEffects() var color = skipTracerFactionColor ? aConst.LinearTracerColor : aConst.TracerFactionColor == FactionColor.Foreground ? FgFactionColor : BgFactionColor; var segmentColor = skipSegFactionColor ? aConst.LinearSegmentColor : aConst.SegFactionColor == FactionColor.Foreground ? FgFactionColor : BgFactionColor; - if (aConst.LineColorVariance) + if (aConst.LineColorVariance && skipTracerFactionColor) { + MyAPIGateway.Utilities.ShowNotification("Here", 200); var tracerStart = aConst.LinearTracerColorStart; var tracerEnd = aConst.LinearTracerColorEnd; // gross inlined random @@ -682,7 +683,7 @@ internal void LineVariableEffects() } } - if (aConst.SegmentColorVariance) + if (aConst.SegmentColorVariance && skipSegFactionColor) { // gross inlined random var tempX = rnd.Y; From 84202d13fb4ee75d5c1b465e074ca40a5c776446 Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Fri, 26 Apr 2024 08:56:43 -0500 Subject: [PATCH 10/17] Sync --- Data/Scripts/CoreSystems/AudioVisual/AvShot.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs b/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs index 83d83663..b04ba657 100644 --- a/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs +++ b/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs @@ -661,7 +661,6 @@ internal void LineVariableEffects() var segmentColor = skipSegFactionColor ? aConst.LinearSegmentColor : aConst.SegFactionColor == FactionColor.Foreground ? FgFactionColor : BgFactionColor; if (aConst.LineColorVariance && skipTracerFactionColor) { - MyAPIGateway.Utilities.ShowNotification("Here", 200); var tracerStart = aConst.LinearTracerColorStart; var tracerEnd = aConst.LinearTracerColorEnd; // gross inlined random From ee91e4e9eb92189c0583e6627cb2334a2839675b Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Sun, 28 Apr 2024 00:01:19 -0500 Subject: [PATCH 11/17] CloudyMarrow needed clarification --- Data/Scripts/CoreSystems/Support/Localization.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/Scripts/CoreSystems/Support/Localization.cs b/Data/Scripts/CoreSystems/Support/Localization.cs index e6ae5542..da5373ac 100644 --- a/Data/Scripts/CoreSystems/Support/Localization.cs +++ b/Data/Scripts/CoreSystems/Support/Localization.cs @@ -177,7 +177,7 @@ public static class Localization { "WeaponTotalEffect", "Damage" }, { "WeaponTotalEffectAvgDps", "AvgDps" }, { "TerminalOverrideTitle", "Override" }, - { "TerminalOverrideTooltip", "Allow dumb firing weapons that otherwise require a target, for target practice only" }, + { "TerminalOverrideTooltip", "Turns off targeting and tracking so you can forcibly fire the weapon- for practice use only" }, { "TerminalAngularTitle", "Track Angular Motion" }, { "TerminalAngularTooltip", "Adjust aim to account for angular motion of the target" }, { "WeaponInfoHasTarget", "HasTarget" }, From 725199d92e5861bfd716d5af138dd8f82b53efa2 Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Thu, 2 May 2024 18:48:43 -0500 Subject: [PATCH 12/17] Updates - Added SG and LG flare/firework launchers to an exemption - Added some debugging to catch and elusive SharpDX audio error - Removed unused code/vars --- .../Scripts/CoreSystems/AudioVisual/AvShot.cs | 32 ++++++++++++------- .../SerializedConfigs/AmmoConstants.cs | 3 -- .../CoreSystems/Session/SessionEvents.cs | 4 +-- .../CoreSystems/Session/SessionFields.cs | 15 ++------- .../CoreSystems/Session/SessionSupport.cs | 14 -------- .../CoreSystems/Session/SessionTypes.cs | 1 - 6 files changed, 24 insertions(+), 45 deletions(-) diff --git a/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs b/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs index b04ba657..340e50f2 100644 --- a/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs +++ b/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs @@ -1030,21 +1030,29 @@ internal void SetupSounds(double distanceFromCameraSqr) if (AmmoDef.Const.ShotSound) { - if (distanceFromCameraSqr <= AmmoDef.Const.ShotSoundDistSqr && (IsFragment || Weapon.System.FiringSound == WeaponSystem.FiringSoundState.None)) + try //SharpDX bughunting { - FireEmitter = Session.Av.FireEmitters.Count > 0 ? Session.Av.FireEmitters.Pop() : new MyEntity3DSoundEmitter(null); - FireEmitter.CanPlayLoopSounds = true; - FireEmitter.Entity = null; - FireEmitter.SetPosition(Origin); - FireEmitter.PlaySound(AmmoDef.Const.ShotSoundPair, true); + if (distanceFromCameraSqr <= AmmoDef.Const.ShotSoundDistSqr && (IsFragment || Weapon.System.FiringSound == WeaponSystem.FiringSoundState.None)) + { + FireEmitter = Session.Av.FireEmitters.Count > 0 ? Session.Av.FireEmitters.Pop() : new MyEntity3DSoundEmitter(null); + FireEmitter.CanPlayLoopSounds = true; + FireEmitter.Entity = null; + FireEmitter.SetPosition(Origin); + FireEmitter.PlaySound(AmmoDef.Const.ShotSoundPair, true); + } + else if (Weapon.System.FiringSound == WeaponSystem.FiringSoundState.PerShot && distanceFromCameraSqr <= Weapon.System.FiringSoundDistSqr) + { + FireEmitter = Session.Av.FireEmitters.Count > 0 ? Session.Av.FireEmitters.Pop() : new MyEntity3DSoundEmitter(null); + FireEmitter.CanPlayLoopSounds = true; + FireEmitter.Entity = Weapon.Comp.CoreEntity; + FireEmitter.SetPosition(Origin); + FireEmitter.PlaySound(AmmoDef.Const.ShotSoundPair, true); + } } - else if (Weapon.System.FiringSound == WeaponSystem.FiringSoundState.PerShot && distanceFromCameraSqr <= Weapon.System.FiringSoundDistSqr) + catch (Exception e) { - FireEmitter = Session.Av.FireEmitters.Count > 0 ? Session.Av.FireEmitters.Pop() : new MyEntity3DSoundEmitter(null); - FireEmitter.CanPlayLoopSounds = true; - FireEmitter.Entity = Weapon.Comp.CoreEntity; - FireEmitter.SetPosition(Origin); - FireEmitter.PlaySound(AmmoDef.Const.ShotSoundPair, true); + MyLog.Default.Error($"Sound error with ammo: {AmmoDef.AmmoRound} from {Weapon.Comp.SubtypeName} soundID {AmmoDef.Const.ShotSoundPair.SoundId} cuename {AmmoDef.Const.ShotSoundPair.GetCueName()}"); + throw; } } } diff --git a/Data/Scripts/CoreSystems/Definitions/SerializedConfigs/AmmoConstants.cs b/Data/Scripts/CoreSystems/Definitions/SerializedConfigs/AmmoConstants.cs index 9e0810cc..4e5f6ca8 100644 --- a/Data/Scripts/CoreSystems/Definitions/SerializedConfigs/AmmoConstants.cs +++ b/Data/Scripts/CoreSystems/Definitions/SerializedConfigs/AmmoConstants.cs @@ -396,9 +396,6 @@ internal AmmoConstants(WeaponSystem.AmmoType ammo, WeaponDefinition wDef, Weapon else if (ammo.AmmoDef.Ejection.Type == AmmoDef.EjectionDef.SpawnType.Particle && !string.IsNullOrEmpty(ammo.AmmoDef.AmmoGraphics.Particles.Eject.Name)) HasEjectEffect = true; - if (AmmoItem.Content != null && !Session.I.AmmoItems.ContainsKey(AmmoItem.ItemId)) - Session.I.AmmoItems[AmmoItem.ItemId] = AmmoItem; - var fragGuidedAmmo = false; var fragAntiSmart = false; var fragTargetOverride = false; diff --git a/Data/Scripts/CoreSystems/Session/SessionEvents.cs b/Data/Scripts/CoreSystems/Session/SessionEvents.cs index 3424bbb1..d714702e 100644 --- a/Data/Scripts/CoreSystems/Session/SessionEvents.cs +++ b/Data/Scripts/CoreSystems/Session/SessionEvents.cs @@ -621,8 +621,6 @@ private bool FindPlayer(IMyPlayer player, long id) SendPlayerConnectionUpdate(id, true); SendServerStartup(player.SteamUserId); } - else if (MpActive && MultiplayerId == player.SteamUserId && JokePlayerList.Contains(player.SteamUserId)) - PracticalJokes(player.SteamUserId); } return false; } @@ -636,7 +634,7 @@ private void BuildPlayerMap(IMyPlayer player, long id) player.Character.Components.TryGet(out targetLock); } - Players[id] = new PlayerMap { Player = player, PlayerId = id, TargetFocus = targetFocus, TargetLock = targetLock, Blessed = BlessedPlayers.Contains(player.SteamUserId)}; + Players[id] = new PlayerMap { Player = player, PlayerId = id, TargetFocus = targetFocus, TargetLock = targetLock}; } internal void OnPlayerControl(MyEntity exitEntity, MyEntity enterEntity) diff --git a/Data/Scripts/CoreSystems/Session/SessionFields.cs b/Data/Scripts/CoreSystems/Session/SessionFields.cs index 613d57a0..ddb61553 100644 --- a/Data/Scripts/CoreSystems/Session/SessionFields.cs +++ b/Data/Scripts/CoreSystems/Session/SessionFields.cs @@ -182,7 +182,6 @@ public partial class Session internal readonly Dictionary ArmorCubes = new Dictionary(); internal readonly Dictionary PrunedPacketsToClient = new Dictionary(); internal readonly Dictionary IdToCompMap = new Dictionary(); - internal readonly Dictionary AmmoItems = new Dictionary(); internal readonly Dictionary KeyMap = new Dictionary(); internal readonly Dictionary MouseMap = new Dictionary(); internal readonly Dictionary> AmmoValuesMap = new Dictionary>(); @@ -501,16 +500,6 @@ public partial class Session internal bool DirtyGrid; internal bool AuthorConnected; - internal readonly HashSet BlessedPlayers = new HashSet() - { - //76561198339035377 -- Most cherished of humanity - }; - - internal readonly HashSet JokePlayerList = new HashSet() - { - }; - - internal readonly HashSet VanillaUpgradeModuleHashes = new HashSet() { "LargeProductivityModule", "LargeEffectivenessModule", "LargeEnergyModule", @@ -525,7 +514,9 @@ public partial class Session internal readonly HashSet VanillaWeaponCompatible = new HashSet() { - "Large_SC_LaserDrillTurret", + "Large_SC_LaserDrillTurret", + "LargeFlareLauncher", + "SmallFlareLauncher", }; internal readonly Dictionary VanillaLeadGroupMatch = new Dictionary() diff --git a/Data/Scripts/CoreSystems/Session/SessionSupport.cs b/Data/Scripts/CoreSystems/Session/SessionSupport.cs index 929a9835..55bed669 100644 --- a/Data/Scripts/CoreSystems/Session/SessionSupport.cs +++ b/Data/Scripts/CoreSystems/Session/SessionSupport.cs @@ -1100,20 +1100,6 @@ internal void ReallyStupidKeenShit() //aka block group removal of individual blo CounterKeenLogMessage(false); } - private void PracticalJokes(ulong playerSteamUserId) - { - string[] jokeArray; - if (JokeCollection.TryGetValue(playerSteamUserId, out jokeArray)) - { - var messageIndex = MyUtils.GetRandomInt(0, jokeArray.Length); - MyAPIGateway.Utilities.ShowNotification(jokeArray[messageIndex], 10000, "Red"); - } - } - - internal Dictionary JokeCollection = new Dictionary - { - }; - internal void CheckToolbarForVanilla(MyCubeBlock cube) { string message = null; diff --git a/Data/Scripts/CoreSystems/Session/SessionTypes.cs b/Data/Scripts/CoreSystems/Session/SessionTypes.cs index 8c42d3f6..bd9d00fe 100644 --- a/Data/Scripts/CoreSystems/Session/SessionTypes.cs +++ b/Data/Scripts/CoreSystems/Session/SessionTypes.cs @@ -960,7 +960,6 @@ public class PlayerMap public long PlayerId; public MyTargetFocusComponent TargetFocus; public MyTargetLockingComponent TargetLock; - public bool Blessed; } public class GridGroupMap From bd3b2f11fa283d2ccdb8590557bac53ca8b3c0d3 Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Sat, 18 May 2024 19:41:43 -0500 Subject: [PATCH 13/17] smarter anti smart v2 --- .../Definitions/CoreDefinitions.cs | 1 + .../SerializedConfigs/AmmoConstants.cs | 8 ++--- .../CoreSystems/Projectiles/Projectile.cs | 36 ++++++++++++++++++- .../CoreSystems/Projectiles/Projectiles.cs | 2 +- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs b/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs index b13d4cd0..26043637 100644 --- a/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs +++ b/Data/Scripts/CoreSystems/Definitions/CoreDefinitions.cs @@ -1088,6 +1088,7 @@ public enum EwarType Push, Pull, Tractor, + AntiSmartv2, } public enum EwarMode diff --git a/Data/Scripts/CoreSystems/Definitions/SerializedConfigs/AmmoConstants.cs b/Data/Scripts/CoreSystems/Definitions/SerializedConfigs/AmmoConstants.cs index ff911f6b..b74402a4 100644 --- a/Data/Scripts/CoreSystems/Definitions/SerializedConfigs/AmmoConstants.cs +++ b/Data/Scripts/CoreSystems/Definitions/SerializedConfigs/AmmoConstants.cs @@ -368,7 +368,7 @@ internal AmmoConstants(WeaponSystem.AmmoType ammo, WeaponDefinition wDef, Weapon if (hasTimed) fragHasTimedSpawn = true; - if (ammoType.Ewar.Type == EwarType.AntiSmart) + if (ammoType.Ewar.Type == EwarType.AntiSmart || ammoType.Ewar.Type == EwarType.AntiSmartv2) fragAntiSmart = true; if (hasGuidance && ammoType.Trajectory.Smarts.OverideTarget) @@ -887,7 +887,7 @@ private void ComputeAmmoPattern(WeaponSystem.AmmoType ammo, WeaponSystem system, if (!patternGuidedAmmo && hasGuidance) patternGuidedAmmo = true; - if (!patternAntiSmart && ammoDef.Ewar.Type == EwarType.AntiSmart) + if (!patternAntiSmart && (ammoDef.Ewar.Type == EwarType.AntiSmart || ammoDef.Ewar.Type == EwarType.AntiSmartv2)) patternAntiSmart = true; if (hasGuidance && ammoDef.Trajectory.Smarts.OverideTarget) patternTargetOverride = true; @@ -902,7 +902,7 @@ private void ComputeAmmoPattern(WeaponSystem.AmmoType ammo, WeaponSystem system, } hasGuidedAmmo = fragGuidedAmmo || patternGuidedAmmo || ammo.AmmoDef.Trajectory.Guidance != TrajectoryDef.GuidanceType.None; - hasAntiSmart = fragAntiSmart || patternAntiSmart || ammo.AmmoDef.Ewar.Type == EwarType.AntiSmart; + hasAntiSmart = fragAntiSmart || patternAntiSmart || ammo.AmmoDef.Ewar.Type == EwarType.AntiSmart || ammo.AmmoDef.Ewar.Type == EwarType.AntiSmartv2; hasTargetOverride = fragTargetOverride || patternTargetOverride || OverrideTarget; } @@ -954,7 +954,7 @@ private void AreaEffects(AmmoDef ammoDef, out float byBlockHitDepth, out float e largestHitSize = Math.Max(byBlockHitRadius, Math.Max(endOfLifeRadius, ewarEffectSize)); eWar = ammoDef.Ewar.Enable; - nonAntiSmart = !eWar || ewarType != EwarType.AntiSmart; + nonAntiSmart = !eWar || !(ewarType == EwarType.AntiSmart || ewarType == EwarType.AntiSmartv2); eWarFieldTrigger = eWar && EwarField && ammoDef.Ewar.Field.TriggerRange > 0; minArmingTime = ammoDef.AreaOfDamage.EndOfLife.MinArmingTime; if (ammoDef.AreaOfDamage.ByBlockHit.Enable) byBlockHitDepth = ammoDef.AreaOfDamage.ByBlockHit.Depth <= 0 ? (float)ammoDef.AreaOfDamage.ByBlockHit.Radius : ammoDef.AreaOfDamage.ByBlockHit.Depth; diff --git a/Data/Scripts/CoreSystems/Projectiles/Projectile.cs b/Data/Scripts/CoreSystems/Projectiles/Projectile.cs index 648a4fa5..95df0a8c 100644 --- a/Data/Scripts/CoreSystems/Projectiles/Projectile.cs +++ b/Data/Scripts/CoreSystems/Projectiles/Projectile.cs @@ -157,7 +157,7 @@ internal void Start() ai.ProjectileTicker = Session.I.Tick; Info.ObjectsHit = 0; Info.BaseHealthPool = aConst.Health; - Info.BaseEwarPool = aConst.Health; + Info.BaseEwarPool = (float)(aConst.EwarType == AntiSmartv2 ? aConst.EwarStrength : aConst.Health); if (aConst.IsSmart || aConst.IsDrone) { @@ -3414,6 +3414,40 @@ internal void EwarEffects() } s.EwaredProjectiles.Clear(); return; + case AntiSmartv2: + if (Info.BaseEwarPool > 0) + { + var eWarSphere2 = new BoundingSphereD(Position, aConst.EwarRadius); + var s2 = Session.I; + DynTrees.GetAllProjectilesInSphere(Session.I, ref eWarSphere2, s2.EwaredProjectiles, false); + for (int j = 0; j < s2.EwaredProjectiles.Count; j++) + { + var netted = s2.EwaredProjectiles[j]; + + if (!netted.Info.Ai.MarkedForClose && eWarSphere2.Intersects(new BoundingSphereD(netted.Position, netted.Info.AmmoDef.Const.CollisionSize))) + { + if (netted.Info.Ai.TopEntityMap.GroupMap.Construct.ContainsKey(Info.Weapon.Comp.TopEntity) || netted.Info.Target.TargetState == Target.TargetStates.IsProjectile || netted.State != ProjectileState.Alive) continue; + + var nStorage = netted.Info.Storage; + var nAconst = netted.Info.AmmoDef.Const; + if (nStorage.RequestedStage >= 0 && nStorage.RequestedStage < nAconst.ApproachesCount && nAconst.Approaches[nStorage.RequestedStage].IgnoreAntiSmart) + continue; + if (Info.Random.NextDouble() * 100f < aConst.PulseChance || !aConst.EwarField) + { + if (Info.BaseEwarPool - netted.Info.AmmoDef.Const.Health >= 0) + { + Info.BaseEwarPool -= netted.Info.AmmoDef.Const.Health; + Info.EwarActive = true; + netted.Info.Target.TargetObject = this; + netted.Info.Target.TargetState = Target.TargetStates.IsProjectile; + Seekers.Add(netted); + } + } + } + } + s2.EwaredProjectiles.Clear(); + } + return; case Push: if (offensiveEwarReady && Info.Random.NextDouble() * 100f <= aConst.PulseChance || !aConst.EwarField) Info.EwarActive = true; diff --git a/Data/Scripts/CoreSystems/Projectiles/Projectiles.cs b/Data/Scripts/CoreSystems/Projectiles/Projectiles.cs index 83a42fb7..ce3f0918 100644 --- a/Data/Scripts/CoreSystems/Projectiles/Projectiles.cs +++ b/Data/Scripts/CoreSystems/Projectiles/Projectiles.cs @@ -339,7 +339,7 @@ private void CheckHits() ++_beamCount; var ewarTriggered = aConst.EwarFieldTrigger && info.ExpandingEwarField; - var useEwarFieldSphere = (ewarTriggered || info.EwarActive) && aConst.EwarField && aConst.EwarType != WeaponDefinition.AmmoDef.EwarDef.EwarType.AntiSmart; + var useEwarFieldSphere = (ewarTriggered || info.EwarActive) && aConst.EwarField && !(aConst.EwarType == WeaponDefinition.AmmoDef.EwarDef.EwarType.AntiSmart || aConst.EwarType == WeaponDefinition.AmmoDef.EwarDef.EwarType.AntiSmartv2); var ewarRadius = !info.ExpandingEwarField ? aConst.EwarRadius : info.TriggerGrowthSteps < aConst.FieldGrowTime ? info.TriggerMatrix.Scale.AbsMax() : aConst.EwarRadius; p.Beam = useEwarFieldSphere ? new LineD(p.Position + (-p.Direction * ewarRadius), p.Position + (p.Direction * ewarRadius)) : new LineD(p.LastPosition, p.Position); var checkBeam = aConst.CheckFutureIntersection ? new LineD(p.Beam.From, p.Beam.From + p.Beam.Direction * (p.Beam.Length + aConst.FutureIntersectionRange), p.Beam.Length + aConst.FutureIntersectionRange) : p.Beam; From 644c55e83d2090abd1a412044bf02fd0c7994c12 Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Sun, 19 May 2024 12:20:23 -0500 Subject: [PATCH 14/17] sequencing BurstCount fix --- Data/Scripts/CoreSystems/EntityComp/Parts/Weapon/WeaponData.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Data/Scripts/CoreSystems/EntityComp/Parts/Weapon/WeaponData.cs b/Data/Scripts/CoreSystems/EntityComp/Parts/Weapon/WeaponData.cs index 90f0d25d..0882f471 100644 --- a/Data/Scripts/CoreSystems/EntityComp/Parts/Weapon/WeaponData.cs +++ b/Data/Scripts/CoreSystems/EntityComp/Parts/Weapon/WeaponData.cs @@ -135,6 +135,8 @@ internal void Load() if (w.System.Values.HardPoint.HardWare.CriticalReaction.DefaultArmedTimer > Repo.Values.Set.Overrides.ArmedTimer) Repo.Values.Set.Overrides.ArmedTimer = w.System.Values.HardPoint.HardWare.CriticalReaction.DefaultArmedTimer; + if (Comp.HasDisabledBurst) + Repo.Values.Set.Overrides.BurstCount = w.System.Values.HardPoint.Loading.ShotsInBurst; } } From dd09bd690289b6afc6f4a8cb26350bae873c50b2 Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Fri, 24 May 2024 10:27:43 -0500 Subject: [PATCH 15/17] bugfix - Added RegisterSubGrid error handling for a modified FatBlocks collection - Repel tooltip note clarification --- Data/Scripts/CoreSystems/Ai/AiConstruct.cs | 28 +++++++++++-------- .../CoreSystems/Support/Localization.cs | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Data/Scripts/CoreSystems/Ai/AiConstruct.cs b/Data/Scripts/CoreSystems/Ai/AiConstruct.cs index 95a4dc32..cf62a406 100644 --- a/Data/Scripts/CoreSystems/Ai/AiConstruct.cs +++ b/Data/Scripts/CoreSystems/Ai/AiConstruct.cs @@ -59,19 +59,25 @@ public void RegisterSubGrid(MyCubeGrid grid) grid.OnFatBlockAdded += FatBlockAdded; grid.OnFatBlockRemoved += FatBlockRemoved; - SubGridsRegistered[grid] = byte.MaxValue; - - foreach (var cube in grid.GetFatBlocks()) { - - var battery = cube as MyBatteryBlock; - var stator = cube as IMyMotorStator; - var tool = cube as IMyShipToolBase; - var offense = cube as IMyOffensiveCombatBlock; - - if (battery != null || cube.HasInventory || stator != null || tool != null || offense != null) + try + { + foreach (var cube in grid.GetFatBlocks()) { - FatBlockAdded(cube); + var battery = cube as MyBatteryBlock; + var stator = cube as IMyMotorStator; + var tool = cube as IMyShipToolBase; + var offense = cube as IMyOffensiveCombatBlock; + + if (battery != null || cube.HasInventory || stator != null || tool != null || offense != null) + { + FatBlockAdded(cube); + } } + SubGridsRegistered[grid] = byte.MaxValue; + } + catch (Exception e) + { + Log.Line("Exception in RegisterSubGrid, delaying until next update " + e); } } diff --git a/Data/Scripts/CoreSystems/Support/Localization.cs b/Data/Scripts/CoreSystems/Support/Localization.cs index da5373ac..31d5c05c 100644 --- a/Data/Scripts/CoreSystems/Support/Localization.cs +++ b/Data/Scripts/CoreSystems/Support/Localization.cs @@ -65,7 +65,7 @@ public static class Localization { "TerminalSubSystemsTitle", "Target SubSystems" }, { "TerminalSubSystemsTooltip", "Target specific SubSystems of a target" }, { "TerminalRepelTitle", "Repel Mode" }, - { "TerminalRepelTooltip", "Aggressively focus and repel small threats" }, + { "TerminalRepelTooltip", "Aggressively focus on and repel small threats (not projectiles)" }, { "TerminalPickAmmoTitle", "Pick Ammo" }, { "TerminalPickAmmoTooltip", "Select the ammo type to use" }, { "TerminalPickSubSystemTitle", "Pick SubSystem" }, From fe17b134ef6ec60659f2dd10608ebdda1d8b00df Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Sat, 25 May 2024 22:34:49 -0500 Subject: [PATCH 16/17] Proj v Proj bugfixes --- Data/Scripts/CoreSystems/Ai/AiConstruct.cs | 27 ++---- .../CoreSystems/Session/SessionDamageMgr.cs | 97 ++++++++++--------- 2 files changed, 62 insertions(+), 62 deletions(-) diff --git a/Data/Scripts/CoreSystems/Ai/AiConstruct.cs b/Data/Scripts/CoreSystems/Ai/AiConstruct.cs index cf62a406..781738e7 100644 --- a/Data/Scripts/CoreSystems/Ai/AiConstruct.cs +++ b/Data/Scripts/CoreSystems/Ai/AiConstruct.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using CoreSystems.Platform; using CoreSystems.Projectiles; using Sandbox.Game.Entities; @@ -58,27 +59,17 @@ public void RegisterSubGrid(MyCubeGrid grid) grid.Flags |= (EntityFlags)(1 << 31); grid.OnFatBlockAdded += FatBlockAdded; grid.OnFatBlockRemoved += FatBlockRemoved; - - try + foreach (var cube in grid.GetFatBlocks().ToArray()) { - foreach (var cube in grid.GetFatBlocks()) - { - var battery = cube as MyBatteryBlock; - var stator = cube as IMyMotorStator; - var tool = cube as IMyShipToolBase; - var offense = cube as IMyOffensiveCombatBlock; + var battery = cube as MyBatteryBlock; + var stator = cube as IMyMotorStator; + var tool = cube as IMyShipToolBase; + var offense = cube as IMyOffensiveCombatBlock; - if (battery != null || cube.HasInventory || stator != null || tool != null || offense != null) - { - FatBlockAdded(cube); - } - } - SubGridsRegistered[grid] = byte.MaxValue; - } - catch (Exception e) - { - Log.Line("Exception in RegisterSubGrid, delaying until next update " + e); + if (battery != null || cube.HasInventory || stator != null || tool != null || offense != null) + FatBlockAdded(cube); } + SubGridsRegistered[grid] = byte.MaxValue; } public void UnRegisterSubGrid(MyCubeGrid grid) diff --git a/Data/Scripts/CoreSystems/Session/SessionDamageMgr.cs b/Data/Scripts/CoreSystems/Session/SessionDamageMgr.cs index 1ae3598f..ef8ddfe7 100644 --- a/Data/Scripts/CoreSystems/Session/SessionDamageMgr.cs +++ b/Data/Scripts/CoreSystems/Session/SessionDamageMgr.cs @@ -1008,15 +1008,26 @@ private void DamageProjectile(HitEntity hitEnt, ProInfo attacker) scaledDamage *= fallOffMultipler; } + //Rework of projectile on projectile damage calcs, as previously you could end up with a high primary damage projectile + //unintentionally surviving multiple hits and doing nearly infinite damage against other projectiles. This was more apparent + //with smarts that would select and chase a new target. Projectiles with EOL detonations could also pop multiple times without dying. + //If your attacking projectile has a health > 0, it will deduct the HealthHitModifier damage done to the target from its own health. It will die once health hits zero or less + //If your attacking projectile has a health = 0, the HealthHitModifier damage it does will be deducted from the primary damage field. It will die once damage hits zero or less + //In either case, a projectile with EOL will detonate on hitting another projectile and die + + var deductFromAttackerHealth = attacker.AmmoDef.Health > 0; if (scaledDamage >= objHp) { - - var safeObjHp = objHp <= 0 ? 0.0000001f : objHp; - var remaining = (scaledDamage / safeObjHp) / damageScale; + attacker.DamageDoneProj += (long)objHp; + if (deductFromAttackerHealth) + { + attacker.BaseHealthPool -= objHp; + if (attacker.BaseHealthPool <= 0) + attacker.BaseDamagePool = 0; + } + else + attacker.BaseDamagePool -= objHp; - attacker.DamageDoneProj += (long)remaining; - attacker.BaseDamagePool -= remaining; - pTarget.Info.BaseHealthPool = 0; var requiresPdSync = AdvSyncClient && pTarget.Info.AmmoDef.Const.PdDeathSync && pTarget.Info.SyncId != ulong.MaxValue; @@ -1028,17 +1039,17 @@ private void DamageProjectile(HitEntity hitEnt, ProInfo attacker) pTarget.Info.Storage.SyncId = ulong.MaxValue; } */ - - if (attacker.AmmoDef.Const.EndOfLifeDamage > 0 && attacker.AmmoDef.Const.EndOfLifeAoe && attacker.RelativeAge >= attacker.AmmoDef.Const.MinArmingTime) - DetonateProjectile(hitEnt, attacker); } else { attacker.BaseDamagePool = 0; attacker.DamageDoneProj += (long)scaledDamage; pTarget.Info.BaseHealthPool -= scaledDamage; - DetonateProjectile(hitEnt, attacker); } + + if (attacker.AmmoDef.Const.EndOfLifeDamage > 0 && attacker.AmmoDef.Const.EndOfLifeAoe && attacker.RelativeAge >= attacker.AmmoDef.Const.MinArmingTime) + DetonateProjectile(hitEnt, attacker); + if (GlobalDamageHandlerActive) { attacker.ProHits = attacker.ProHits != null && ProHitPool.Count > 0 ? ProHitPool.Pop() : new List>(); attacker.ProHits.Add(new MyTuple(hitEnt.Intersection.To, pTarget.Info.Id, scaledDamage)); @@ -1047,52 +1058,50 @@ private void DamageProjectile(HitEntity hitEnt, ProInfo attacker) private void DetonateProjectile(HitEntity hitEnt, ProInfo attacker) { - if (attacker.AmmoDef.Const.EndOfLifeDamage > 0 && attacker.AmmoDef.Const.EndOfLifeAoe && attacker.RelativeAge >= attacker.AmmoDef.Const.MinArmingTime) + var areaSphere = new BoundingSphereD(hitEnt.Projectile.Position, attacker.AmmoDef.Const.EndOfLifeRadius); + foreach (var sTarget in attacker.Ai.LiveProjectile.Keys) { - var areaSphere = new BoundingSphereD(hitEnt.Projectile.Position, attacker.AmmoDef.Const.EndOfLifeRadius); - foreach (var sTarget in attacker.Ai.LiveProjectile.Keys) + if (areaSphere.Contains(sTarget.Position) != ContainmentType.Disjoint && sTarget.State == Projectile.ProjectileState.Alive) { - if (areaSphere.Contains(sTarget.Position) != ContainmentType.Disjoint && sTarget.State == Projectile.ProjectileState.Alive) - { - var objHp = sTarget.Info.BaseHealthPool; - var integrityCheck = attacker.AmmoDef.DamageScales.MaxIntegrity > 0; - if (integrityCheck && objHp > attacker.AmmoDef.DamageScales.MaxIntegrity) continue; + var objHp = sTarget.Info.BaseHealthPool; + var integrityCheck = attacker.AmmoDef.DamageScales.MaxIntegrity > 0; + if (integrityCheck && objHp > attacker.AmmoDef.DamageScales.MaxIntegrity) continue; - if (sTarget.Info.AmmoDef.Const.ArmedWhenHit) - sTarget.Info.ObjectsHit++; + if (sTarget.Info.AmmoDef.Const.ArmedWhenHit) + sTarget.Info.ObjectsHit++; - var damageScale = (float)attacker.AmmoDef.Const.HealthHitModifier; - if (attacker.AmmoDef.Const.VirtualBeams) damageScale *= attacker.Weapon.WeaponCache.Hits; - var scaledDamage = 1 * damageScale; + var damageScale = (float)attacker.AmmoDef.Const.HealthHitModifier; + if (attacker.AmmoDef.Const.VirtualBeams) damageScale *= attacker.Weapon.WeaponCache.Hits; + var scaledDamage = 1 * damageScale; - if (scaledDamage >= objHp) - { - attacker.DamageDoneProj += (long)objHp; - sTarget.Info.BaseHealthPool = 0; - var requiresPdSync = AdvSyncClient && sTarget.Info.AmmoDef.Const.PdDeathSync && sTarget.Info.SyncId != ulong.MaxValue; - sTarget.State = !requiresPdSync ? Projectile.ProjectileState.Destroy : Projectile.ProjectileState.ClientPhantom; - /* - if (requiresPdSync && PdServer && PointDefenseSyncMonitor.ContainsKey(sTarget.Info.Storage.SyncId)) - { - ProtoPdSyncMonitor.Collection.Add(sTarget.Info.Storage.SyncId); - sTarget.Info.Storage.SyncId = ulong.MaxValue; - } - */ - } - else + if (scaledDamage >= objHp) + { + attacker.DamageDoneProj += (long)objHp; + sTarget.Info.BaseHealthPool = 0; + var requiresPdSync = AdvSyncClient && sTarget.Info.AmmoDef.Const.PdDeathSync && sTarget.Info.SyncId != ulong.MaxValue; + sTarget.State = !requiresPdSync ? Projectile.ProjectileState.Destroy : Projectile.ProjectileState.ClientPhantom; + /* + if (requiresPdSync && PdServer && PointDefenseSyncMonitor.ContainsKey(sTarget.Info.Storage.SyncId)) { - sTarget.Info.BaseHealthPool -= scaledDamage; - attacker.DamageDoneProj += (long)scaledDamage; + ProtoPdSyncMonitor.Collection.Add(sTarget.Info.Storage.SyncId); + sTarget.Info.Storage.SyncId = ulong.MaxValue; } + */ + } + else + { + sTarget.Info.BaseHealthPool -= scaledDamage; + attacker.DamageDoneProj += (long)scaledDamage; + } - if (GlobalDamageHandlerActive) { - attacker.ProHits = attacker.ProHits != null && ProHitPool.Count > 0 ? ProHitPool.Pop() : new List>(); - attacker.ProHits.Add(new MyTuple(hitEnt.Intersection.To, hitEnt.Projectile.Info.Id, scaledDamage)); - } + if (GlobalDamageHandlerActive) { + attacker.ProHits = attacker.ProHits != null && ProHitPool.Count > 0 ? ProHitPool.Pop() : new List>(); + attacker.ProHits.Add(new MyTuple(hitEnt.Intersection.To, hitEnt.Projectile.Info.Id, scaledDamage)); } } } + attacker.BaseDamagePool = 0; } private void DamageVoxel(HitEntity hitEnt, ProInfo info, HitEntity.Type type) From 48534b07f517ae8051c078e285da06e55dad10cb Mon Sep 17 00:00:00 2001 From: BDCarrillo <90526940+BDCarrillo@users.noreply.github.com> Date: Tue, 28 May 2024 23:16:52 -0500 Subject: [PATCH 17/17] Casting a net for errors --- Data/Scripts/CoreSystems/Ai/AiConstruct.cs | 38 +++++++++++++++---- Data/Scripts/CoreSystems/Ai/AiEvents.cs | 5 +++ .../Scripts/CoreSystems/AudioVisual/AvShot.cs | 5 ++- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/Data/Scripts/CoreSystems/Ai/AiConstruct.cs b/Data/Scripts/CoreSystems/Ai/AiConstruct.cs index 781738e7..c9350525 100644 --- a/Data/Scripts/CoreSystems/Ai/AiConstruct.cs +++ b/Data/Scripts/CoreSystems/Ai/AiConstruct.cs @@ -59,15 +59,39 @@ public void RegisterSubGrid(MyCubeGrid grid) grid.Flags |= (EntityFlags)(1 << 31); grid.OnFatBlockAdded += FatBlockAdded; grid.OnFatBlockRemoved += FatBlockRemoved; - foreach (var cube in grid.GetFatBlocks().ToArray()) + + //BDC Temp debugging + var tempBlockArray = grid.GetFatBlocks().ToArray(); + try { - var battery = cube as MyBatteryBlock; - var stator = cube as IMyMotorStator; - var tool = cube as IMyShipToolBase; - var offense = cube as IMyOffensiveCombatBlock; + foreach (var cube in grid.GetFatBlocks()) + { + var battery = cube as MyBatteryBlock; + var stator = cube as IMyMotorStator; + var tool = cube as IMyShipToolBase; + var offense = cube as IMyOffensiveCombatBlock; - if (battery != null || cube.HasInventory || stator != null || tool != null || offense != null) - FatBlockAdded(cube); + if (battery != null || cube.HasInventory || stator != null || tool != null || offense != null) + FatBlockAdded(cube); + } + } + catch (Exception ex) + { + var modifiedBlockArray = grid.GetFatBlocks(); + var msg = $"Original GetFatBlocks contained {tempBlockArray.Length} items, modified contains {modifiedBlockArray.Count}"; + foreach (var original in tempBlockArray) + { + if(!modifiedBlockArray.Contains(original)) + msg += $"Block {original.DisplayName} was removed \n"; + } + foreach (var modified in modifiedBlockArray) + { + if (!tempBlockArray.Contains(modified)) + msg += $"Block {modified.DisplayName} was added \n"; + } + Log.Line(msg); + MyLog.Default.WriteLine(msg); + throw ex; } SubGridsRegistered[grid] = byte.MaxValue; } diff --git a/Data/Scripts/CoreSystems/Ai/AiEvents.cs b/Data/Scripts/CoreSystems/Ai/AiEvents.cs index 6dfe58d2..fd8d5832 100644 --- a/Data/Scripts/CoreSystems/Ai/AiEvents.cs +++ b/Data/Scripts/CoreSystems/Ai/AiEvents.cs @@ -8,6 +8,7 @@ using VRage.Collections; using VRage.Game.Entity; using VRage.Game.ModAPI; +using VRage.Utils; using VRageMath; namespace CoreSystems.Support @@ -186,6 +187,10 @@ internal void FatBlockAdded(MyCubeBlock cube) if (Session.I.IsServer) { cube.CubeGrid.RemoveBlock(cube.SlimBlock, true); + //BDC Temp debugging + var msg = $"WeaponCore Removed {cube.BlockDefinition.Id.SubtypeId} block due to placement violations"; + Log.Line(msg); + MyLog.Default.WriteLine(msg); } } } diff --git a/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs b/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs index 340e50f2..2e4ab009 100644 --- a/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs +++ b/Data/Scripts/CoreSystems/AudioVisual/AvShot.cs @@ -1051,8 +1051,9 @@ internal void SetupSounds(double distanceFromCameraSqr) } catch (Exception e) { - MyLog.Default.Error($"Sound error with ammo: {AmmoDef.AmmoRound} from {Weapon.Comp.SubtypeName} soundID {AmmoDef.Const.ShotSoundPair.SoundId} cuename {AmmoDef.Const.ShotSoundPair.GetCueName()}"); - throw; + MyLog.Default.Error($"Sound error with ammo: {AmmoDef.AmmoRound} from {Weapon.Comp.TerminalBlock.DisplayName} soundID {AmmoDef.Const.ShotSoundPair.SoundId} cuename {AmmoDef.Const.ShotSoundPair.GetCueName()}" + + $"FireEmitter.Entity null? {FireEmitter?.Entity == null} \n Origin: {Origin}"); + throw e; } } }