diff --git a/README.md b/README.md index b4eb15b..7e6e47d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # StrategicOperations -**Depends On Abilifier v1.4.1.0 or higher!** +**Depends On Abilifier v1.4.1.0 or higher!,** + +**Versions 3.1.2.4 and higher depend on CBTBehaviorsEnhanced 2.3.5 or higher** **Versions 3.1.0.0 and higher requires modtek v3 or higher** @@ -518,7 +520,8 @@ settings in the mod.json: "b": 255 } ], - "BAMountReminderText": "Shift-click unit in drop slot to set carrier" + "BAMountReminderText": "Shift-click unit in drop slot to set carrier", + "MeleeOnSwarmAttacks": true ``` `enableLogging` - bool, enable logging @@ -774,6 +777,8 @@ Using the following settings, ClanGhostBear and ClanWolf have baseline 30% chanc `BAMountPairColors` - list of color configs (same format as `MountIndicatorColor` setting) that defines possible overlay colors for pre-mission squad and carrier assignments. `BAMountReminderText` - controls reminder text for shift-click to assign squads to carriers, which is displayed below the mech widget in the lance config screen + +`MeleeOnSwarmAttacks` - if true, BA will initiate a melee weapon attack when swarming (and when attacking during an ongoing swarm). ## Spawns diff --git a/StrategicOperations/StrategicOperations/Framework/Classes.cs b/StrategicOperations/StrategicOperations/Framework/Classes.cs index bdf6df2..625f94e 100644 --- a/StrategicOperations/StrategicOperations/Framework/Classes.cs +++ b/StrategicOperations/StrategicOperations/Framework/Classes.cs @@ -5,6 +5,7 @@ using BattleTech; using BattleTech.Data; using BattleTech.UI; +using CBTBehaviorsEnhanced.MeleeStates; using CustomComponents; using CustomUnits; using HBS.Collections; @@ -13,6 +14,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using UnityEngine; +using static MonoMod.Cil.RuntimeILReferenceBag.FastDelegateInvokers; namespace StrategicOperations.Framework { @@ -1342,17 +1344,41 @@ public override void CompleteOrders() } var weps = squad2.Weapons.Where(x => x.IsEnabled && x.HasAmmo).ToList(); - var loc = ModState.BADamageTrackers[squad2.GUID].BA_MountedLocations.Values - .GetRandomElement(); - - var attackStackSequence = new AttackStackSequence(squad2, targetActor, - squad2.CurrentPosition, - squad2.CurrentRotation, weps, MeleeAttackType.NotSet, loc, -1); - squad2.Combat.MessageCenter.PublishMessage( - new AddSequenceToStackMessage(attackStackSequence)); + + // var baselineAccuracyModifier = actor.StatCollection.GetValue("AccuracyModifier"); + // actor.StatCollection.Set("AccuracyModifier", -99999.0f); + // ModInit.modLog?.Trace?.Write($"[AbstractActor.DoneWithActor] Actor {actor.DisplayName} getting baselineAccuracyModifer set to {actor.AccuracyModifier}"); + + var loc = ModState.BADamageTrackers[squad2.GUID].BA_MountedLocations.Values.GetRandomElement(); + ModInit.modLog?.Info?.Write( $"[StrategicMovementSequence - CompleteOrders] Creating attack sequence on successful swarm attack targeting location {loc}."); - + + if (squad2 is Mech unitMech && ModInit.modSettings.MeleeOnSwarmAttacks) + { + if (!ModState.SwarmMeleeSequences.ContainsKey(squad2.GUID)) + { + ModState.SwarmMeleeSequences.Add(squad2.GUID, loc); + } + var meleeState = CBTBehaviorsEnhanced.ModState.AddorUpdateMeleeState(squad2, targetActor.CurrentPosition, targetActor, true); + if (meleeState != null) + { + MeleeAttack highestDamageAttackForUI = meleeState.GetHighestDamageAttackForUI(); + CBTBehaviorsEnhanced.ModState.AddOrUpdateSelectedAttack(squad2, highestDamageAttackForUI); + } + MessageCenterMessage meleeInvocationMessage = new MechMeleeInvocation(unitMech, targetActor, weps, targetActor.CurrentPosition); + squad2.Combat.MessageCenter.PublishInvocationExternal(meleeInvocationMessage); + } + else + { + var attackStackSequence = new AttackStackSequence(squad2, targetActor, squad2.CurrentPosition, + squad2.CurrentRotation, weps, MeleeAttackType.NotSet, loc, -1); + squad2.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(attackStackSequence)); + + // actor.StatCollection.Set("AccuracyModifier", baselineAccuracyModifier); + // ModInit.modLog?.Trace?.Write($"[AbstractActor.DoneWithActor] Actor {actor.DisplayName} resetting baselineAccuracyModifer to {actor.AccuracyModifier}"); + + } } //doattacksequencehere diff --git a/StrategicOperations/StrategicOperations/Framework/ModState.cs b/StrategicOperations/StrategicOperations/Framework/ModState.cs index 669bf22..9becf8c 100644 --- a/StrategicOperations/StrategicOperations/Framework/ModState.cs +++ b/StrategicOperations/StrategicOperations/Framework/ModState.cs @@ -9,6 +9,7 @@ namespace StrategicOperations.Framework { public static class ModState { + public static Dictionary SwarmMeleeSequences = new Dictionary(); public static Dictionary AiCmds = new Dictionary(); public static Dictionary AiDealWithBattleArmorCmds = new Dictionary(); @@ -186,6 +187,7 @@ public static void Initialize() public static void ResetAll() { + SwarmMeleeSequences = new Dictionary(); UsedOverlayColors = new List(); UsedOverlayColorsByCarrier = new Dictionary(); PendingPairBAUnit = null; diff --git a/StrategicOperations/StrategicOperations/Framework/Utils.cs b/StrategicOperations/StrategicOperations/Framework/Utils.cs index 167016c..75640a5 100644 --- a/StrategicOperations/StrategicOperations/Framework/Utils.cs +++ b/StrategicOperations/StrategicOperations/Framework/Utils.cs @@ -1661,7 +1661,7 @@ public static HeraldryDef SwapHeraldryColors(HeraldryDef def, DataManager dataMa return newHeraldry; } - public static void TeleportActorVisual(this AbstractActor actor, Vector3 newPosition) + public static void TeleportActorNoResetPathing(this AbstractActor actor, Vector3 newPosition) { actor.CurrentPosition = newPosition; actor.GameRep.transform.position = newPosition; diff --git a/StrategicOperations/StrategicOperations/ModInit.cs b/StrategicOperations/StrategicOperations/ModInit.cs index 969b36c..4af198f 100644 --- a/StrategicOperations/StrategicOperations/ModInit.cs +++ b/StrategicOperations/StrategicOperations/ModInit.cs @@ -183,5 +183,6 @@ class Settings //public List BeaconExcludedContractIDs = new List(); public bool UsingMechAffinityForSwarmBreach = false; public bool ReworkedCarrierEvasion = true; + public bool MeleeOnSwarmAttacks = true; } } \ No newline at end of file diff --git a/StrategicOperations/StrategicOperations/Patches/AI_Patches.cs b/StrategicOperations/StrategicOperations/Patches/AI_Patches.cs index 105aa45..aec6d85 100644 --- a/StrategicOperations/StrategicOperations/Patches/AI_Patches.cs +++ b/StrategicOperations/StrategicOperations/Patches/AI_Patches.cs @@ -3,6 +3,7 @@ using System.Reflection; using Abilifier.Patches; using BattleTech; +using CBTBehaviorsEnhanced.MeleeStates; using CustomUnits; using IRTweaks.Modules.Combat; using StrategicOperations.Framework; @@ -22,18 +23,6 @@ public static void Prefix(ref bool __runOriginal, AITeam __instance, AbstractAct if (!__runOriginal) return; if (unit.HasSwarmingUnits()){ - if (unit is FakeVehicleMech && !unit.HasMovedThisRound && order.OrderType == OrderType.Move || order.OrderType == OrderType.JumpMove || order.OrderType == OrderType.SprintMove) - { - var ability = unit.GetDeswarmerAbilityForAI(true); - if (ability.IsAvailable && !ability.IsActive) - { - ability.Activate(unit, unit); - ModInit.modLog?.Info?.Write($"{unit.DisplayName} {unit.GUID} is vehicle being swarmed. Found movement order, activating erratic maneuvers ability."); - __runOriginal = true; - return; - } - } - if (ModState.AiDealWithBattleArmorCmds.ContainsKey(unit.GUID)) { ModState.AiDealWithBattleArmorCmds[unit.GUID].ability.Activate(unit, unit); @@ -53,6 +42,18 @@ public static void Prefix(ref bool __runOriginal, AITeam __instance, AbstractAct __runOriginal = false; return; } + + if (unit is FakeVehicleMech && !unit.HasMovedThisRound && order.OrderType == OrderType.Move || order.OrderType == OrderType.JumpMove || order.OrderType == OrderType.SprintMove) + { + var ability = unit.GetDeswarmerAbilityForAI(true); + if (ability.IsAvailable && !ability.IsActive) + { + ability.Activate(unit, unit); + ModInit.modLog?.Info?.Write($"{unit.DisplayName} {unit.GUID} is vehicle being swarmed. Found movement order, activating erratic maneuvers ability."); + __runOriginal = true; + return; + } + } } if (unit.IsMountedUnit() && !ModState.StrategicActorTargetInvocationCmds.ContainsKey(unit.GUID)) @@ -96,7 +97,7 @@ public static void Prefix(ref bool __runOriginal, AITeam __instance, AbstractAct } var weps = unit.Weapons.Where(x => x.IsEnabled && x.HasAmmo).ToList(); - if (weps.Count <= 0) + if (weps.Count <= 0 && !ModInit.modSettings.MeleeOnSwarmAttacks) { //dismount, no more weapons...should probably loop back up to try and resupply?? unit.DismountBA(target, Vector3.zero, false); @@ -107,11 +108,29 @@ public static void Prefix(ref bool __runOriginal, AITeam __instance, AbstractAct var loc = ModState.BADamageTrackers[unit.GUID].BA_MountedLocations.Values.GetRandomElement(); //var attackStackSequence = new AttackStackSequence(unit, target, unit.CurrentPosition, unit.CurrentRotation, weps, MeleeAttackType.NotSet, loc, -1); //unit.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(attackStackSequence)); - var vent = unit.HasVentCoolantAbility && unit.CanVentCoolant; - __result = new AttackInvocation(unit, target, weps, MeleeAttackType.NotSet, loc) + + if (unit is Mech unitMech && ModInit.modSettings.MeleeOnSwarmAttacks) + { + if (!ModState.SwarmMeleeSequences.ContainsKey(unit.GUID)) + { + ModState.SwarmMeleeSequences.Add(unit.GUID, loc); + } + var meleeState = CBTBehaviorsEnhanced.ModState.AddorUpdateMeleeState(unit, target.CurrentPosition, target, true); + if (meleeState != null) + { + MeleeAttack highestDamageAttackForUI = meleeState.GetHighestDamageAttackForUI(); + CBTBehaviorsEnhanced.ModState.AddOrUpdateSelectedAttack(unit, highestDamageAttackForUI); + } + __result = new MechMeleeInvocation(unitMech, target, weps, target.CurrentPosition); + } + else { - ventHeatBeforeAttack = vent - }; // making a regular attack invocation here, instead of stacksequence + reserve + var vent = unit.HasVentCoolantAbility && unit.CanVentCoolant; + __result = new AttackInvocation(unit, target, weps, MeleeAttackType.NotSet, loc) + { + ventHeatBeforeAttack = vent + }; // making a regular attack invocation here, instead of stacksequence + reserve + } //if (!unit.HasMovedThisRound) //{ @@ -431,7 +450,7 @@ public static void Prefix(ref bool __runOriginal, CanMoveAndShootWithoutOverheat } var weps = __instance.unit.Weapons.Where(x => x.IsEnabled && x.HasAmmo).ToList(); - if (weps.Count <= 0) + if (weps.Count <= 0 && !ModInit.modSettings.MeleeOnSwarmAttacks) { goto noswarm; } @@ -479,6 +498,7 @@ public static void Prefix(ref bool __runOriginal, CanMoveAndShootWithoutOverheat var deswarm = __instance.unit.GetDeswarmerAbilityForAI(); if (deswarm != null && deswarm?.Def?.Description?.Id != null) { + ModInit.modLog?.Trace?.Write($"[CanMoveAndShootWithoutOverheatingNode] unit {__instance.unit.DisplayName} is being swarmed, found deswarm ability {deswarm.Def.Description.Name}."); if (ModState.AiDealWithBattleArmorCmds.ContainsKey(__instance.unit.GUID)) { if (ModState.AiDealWithBattleArmorCmds[__instance.unit.GUID].active) diff --git a/StrategicOperations/StrategicOperations/Patches/BattleArmorPatches.cs b/StrategicOperations/StrategicOperations/Patches/BattleArmorPatches.cs index 6cbda24..1739d2b 100644 --- a/StrategicOperations/StrategicOperations/Patches/BattleArmorPatches.cs +++ b/StrategicOperations/StrategicOperations/Patches/BattleArmorPatches.cs @@ -6,6 +6,7 @@ using BattleTech.Save; using BattleTech.UI; using BattleTech.UI.TMProWrapper; +using CBTBehaviorsEnhanced.MeleeStates; using CustomActivatableEquipment; using CustomComponents; using CustomUnits; @@ -13,6 +14,7 @@ using HBS.Math; using IRTweaks.Modules.Combat; using Localize; +using Steamworks; using StrategicOperations.Framework; using SVGImporter; using TMPro; @@ -729,7 +731,7 @@ public static void Prefix(ref bool __runOriginal, CombatHUDButtonBase __instance var target = actor.Combat.FindActorByGUID(ModState.PositionLockSwarm[actor.GUID]); ModInit.modLog?.Info?.Write( $"[CombatHUDButtonBase.OnClick] Actor {actor.DisplayName} has active swarm attack on {target.DisplayName}"); - + var weps = actor.Weapons.Where(x => x.IsEnabled && x.HasAmmo).ToList(); // var baselineAccuracyModifier = actor.StatCollection.GetValue("AccuracyModifier"); @@ -737,14 +739,33 @@ public static void Prefix(ref bool __runOriginal, CombatHUDButtonBase __instance // ModInit.modLog?.Trace?.Write($"[AbstractActor.DoneWithActor] Actor {actor.DisplayName} getting baselineAccuracyModifer set to {actor.AccuracyModifier}"); var loc = ModState.BADamageTrackers[actor.GUID].BA_MountedLocations.Values.GetRandomElement(); - var attackStackSequence = new AttackStackSequence(actor, target, actor.CurrentPosition, - actor.CurrentRotation, weps, MeleeAttackType.NotSet, loc, -1); - actor.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(attackStackSequence)); -// actor.StatCollection.Set("AccuracyModifier", baselineAccuracyModifier); -// ModInit.modLog?.Trace?.Write($"[AbstractActor.DoneWithActor] Actor {actor.DisplayName} resetting baselineAccuracyModifer to {actor.AccuracyModifier}"); - __runOriginal = true; - return; + if (actor is Mech unitMech && ModInit.modSettings.MeleeOnSwarmAttacks) + { + if (!ModState.SwarmMeleeSequences.ContainsKey(actor.GUID)) + { + ModState.SwarmMeleeSequences.Add(actor.GUID, loc); + } + var meleeState = CBTBehaviorsEnhanced.ModState.AddorUpdateMeleeState(actor, target.CurrentPosition, target, true); + if (meleeState != null) + { + MeleeAttack highestDamageAttackForUI = meleeState.GetHighestDamageAttackForUI(); + CBTBehaviorsEnhanced.ModState.AddOrUpdateSelectedAttack(actor, highestDamageAttackForUI); + } + MessageCenterMessage meleeInvocationMessage = new MechMeleeInvocation(unitMech, target, weps, target.CurrentPosition); + actor.Combat.MessageCenter.PublishInvocationExternal(meleeInvocationMessage); + } + else + { + var attackStackSequence = new AttackStackSequence(actor, target, actor.CurrentPosition, + actor.CurrentRotation, weps, MeleeAttackType.NotSet, loc, -1); + actor.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(attackStackSequence)); + + // actor.StatCollection.Set("AccuracyModifier", baselineAccuracyModifier); + // ModInit.modLog?.Trace?.Write($"[AbstractActor.DoneWithActor] Actor {actor.DisplayName} resetting baselineAccuracyModifer to {actor.AccuracyModifier}"); + __runOriginal = true; + return; + } } } @@ -1998,6 +2019,36 @@ public static void Postfix(MechRepresentation __instance, bool headlightsActive) } } + [HarmonyPatch(typeof(MechMeleeSequence), "BuildWeaponDirectorSequence", new Type[] { })] + public static class MechMeleeSequence_BuildWeaponDirectorSequence + { + public static void Prefix(ref bool __runOriginal, MechMeleeSequence __instance) + { + if (!__runOriginal) return; + if (ModState.SwarmMeleeSequences.TryGetValue(__instance.OwningMech.GUID, out var loc)) + { + __instance.requestedWeapons.RemoveAll((Weapon x) => x.Type == WeaponType.Melee); + if (__instance.requestedWeapons.Count > 0) + { + __instance.weaponSequence = new AttackStackSequence(__instance.OwningMech, + __instance.MeleeTarget, __instance.moveSequence.FinalPos, + Quaternion.LookRotation(__instance.moveSequence.FinalHeading), __instance.requestedWeapons, + MeleeAttackType.NotSet, loc, 1); + __instance.weaponSequence.willConsumeFiring = false; + __instance.weaponSequence.hasOwningSequence = true; + __instance.weaponSequence.directorSequences[0].isParentMelee = true; + __instance.weaponSequence.RootSequenceGUID = __instance.RootSequenceGUID; + if (__instance.cameraSequence != null) + { + __instance.weaponSequence.SetCamera(__instance.cameraSequence, __instance.MessageIndex); + } + } + ModState.SwarmMeleeSequences.Remove(__instance.OwningMech.GUID); + __runOriginal = false; + } + } + } + [HarmonyPatch(typeof(SelectionStateAbilityInstant), "OnAddToStack", new Type[] { })] public static class SelectionStateAbilityInstant_OnAddToStack { diff --git a/StrategicOperations/StrategicOperations/Patches/StrategicOperationsPatches.cs b/StrategicOperations/StrategicOperations/Patches/StrategicOperationsPatches.cs index 4a89d23..a6f46da 100644 --- a/StrategicOperations/StrategicOperations/Patches/StrategicOperationsPatches.cs +++ b/StrategicOperations/StrategicOperations/Patches/StrategicOperationsPatches.cs @@ -1787,7 +1787,7 @@ public static void Postfix(CustomMechRepresentation __instance) { pos = __instance.parentActor.CurrentPosition + Vector3.down * trackerInfo.Value.Offset + Vector3.up * mech.custGameRep.HeightController.CurrentHeight; - targetActor.TeleportActorVisual(pos); + targetActor.TeleportActorNoResetPathing(pos); if (targetActor is CustomMech customMech) { customMech.custGameRep.j_Root.localRotation = Quaternion.identity; @@ -1800,7 +1800,7 @@ public static void Postfix(CustomMechRepresentation __instance) else { pos = __instance.parentActor.CurrentPosition + Vector3.down * trackerInfo.Value.Offset; - targetActor.TeleportActorVisual(pos); + targetActor.TeleportActorNoResetPathing(pos); if (targetActor is CustomMech customMech) { customMech.custGameRep.j_Root.localRotation = Quaternion.identity; @@ -1832,11 +1832,11 @@ public static void Postfix(CustomMechRepresentation __instance) { pos = __instance.parentActor.CurrentPosition + Vector3.up * mech.custGameRep.HeightController.CurrentHeight; - targetActor.TeleportActorVisual(pos); + targetActor.TeleportActorNoResetPathing(pos); } else { - targetActor.TeleportActorVisual(__instance.parentActor.CurrentPosition); + targetActor.TeleportActorNoResetPathing(__instance.parentActor.CurrentPosition); } targetActor.MountedEvasion(__instance.parentActor); @@ -1856,7 +1856,7 @@ public static void Postfix(CustomMechRepresentation __instance) { var targetActor = combat.FindActorByGUID(targetActorGUID.Key); if (targetActor == null) continue; - targetActor.TeleportActorVisual(__instance.parentActor.CurrentPosition); + targetActor.TeleportActorNoResetPathing(__instance.parentActor.CurrentPosition); targetActor.MountedEvasion(__instance.parentActor); ModInit.modLog?.Debug?.Write( $"[CustomMechRepresentation_GameRepresentation_Update] PositionLockMount- Setting riding unit {targetActor.DisplayName} position to same as carrier unit {__instance.parentActor.DisplayName}"); @@ -1890,7 +1890,7 @@ public static void Postfix(CombatHUD HUD, List positions) { var pos = custMech.CurrentPosition + Vector3.up * custMech.custGameRep.HeightController.CurrentHeight; - squad.TeleportActorVisual(pos); + squad.TeleportActorNoResetPathing(pos); } } } @@ -2030,7 +2030,7 @@ public static void Postfix(MechDisplacementSequence __instance) { pos = __instance.OwningMech.CurrentPosition + Vector3.down * trackerInfo.Value.Offset + Vector3.up * mech.custGameRep.HeightController.CurrentHeight; - targetActor.TeleportActorVisual(pos); + targetActor.TeleportActorNoResetPathing(pos); if (targetActor is CustomMech customMech) { customMech.custGameRep.j_Root.localRotation = Quaternion.identity; @@ -2043,7 +2043,7 @@ public static void Postfix(MechDisplacementSequence __instance) else { pos = __instance.OwningMech.CurrentPosition + Vector3.down * trackerInfo.Value.Offset; - targetActor.TeleportActorVisual(pos); + targetActor.TeleportActorNoResetPathing(pos); if (targetActor is CustomMech customMech) { customMech.custGameRep.j_Root.localRotation = Quaternion.identity; @@ -2075,11 +2075,11 @@ public static void Postfix(MechDisplacementSequence __instance) { pos = __instance.OwningMech.CurrentPosition + Vector3.up * mech.custGameRep.HeightController.CurrentHeight; - targetActor.TeleportActorVisual(pos); + targetActor.TeleportActorNoResetPathing(pos); } else { - targetActor.TeleportActorVisual(__instance.OwningMech.CurrentPosition); + targetActor.TeleportActorNoResetPathing(__instance.OwningMech.CurrentPosition); } targetActor.MountedEvasion(__instance.OwningMech); @@ -2099,7 +2099,7 @@ public static void Postfix(MechDisplacementSequence __instance) { var targetActor = combat.FindActorByGUID(targetActorGUID.Key); if (targetActor == null) continue; - targetActor.TeleportActorVisual(__instance.OwningMech.CurrentPosition); + targetActor.TeleportActorNoResetPathing(__instance.OwningMech.CurrentPosition); targetActor.MountedEvasion(__instance.OwningMech); ModInit.modLog?.Debug?.Write( $"[MechDisplacementSequence_OnComplete] PositionLockMount- Setting riding unit {targetActor.DisplayName} position to same as carrier unit {__instance.OwningMech.DisplayName}"); @@ -2186,7 +2186,7 @@ public static void Postfix(OrderSequence __instance) { pos = __instance.owningActor.CurrentPosition + Vector3.down * trackerInfo.Value.Offset + Vector3.up * mech.custGameRep.HeightController.CurrentHeight; - targetActor.TeleportActorVisual(pos); + targetActor.TeleportActorNoResetPathing(pos); if (targetActor is CustomMech customMech) { customMech.custGameRep.j_Root.localRotation = Quaternion.identity; @@ -2199,7 +2199,7 @@ public static void Postfix(OrderSequence __instance) else { pos = __instance.owningActor.CurrentPosition + Vector3.down * trackerInfo.Value.Offset; - targetActor.TeleportActorVisual(pos); + targetActor.TeleportActorNoResetPathing(pos); if (targetActor is CustomMech customMech) { customMech.custGameRep.j_Root.localRotation = Quaternion.identity; @@ -2231,11 +2231,11 @@ public static void Postfix(OrderSequence __instance) { pos = __instance.owningActor.CurrentPosition + Vector3.up * mech.custGameRep.HeightController.CurrentHeight; - targetActor.TeleportActorVisual(pos); + targetActor.TeleportActorNoResetPathing(pos); } else { - targetActor.TeleportActorVisual(__instance.owningActor.CurrentPosition); + targetActor.TeleportActorNoResetPathing(__instance.owningActor.CurrentPosition); } targetActor.MountedEvasion(__instance.owningActor); @@ -2255,7 +2255,7 @@ public static void Postfix(OrderSequence __instance) { var targetActor = combat.FindActorByGUID(targetActorGUID.Key); if (targetActor == null) continue; - targetActor.TeleportActorVisual(__instance.owningActor.CurrentPosition); + targetActor.TeleportActorNoResetPathing(__instance.owningActor.CurrentPosition); targetActor.MountedEvasion(__instance.owningActor); ModInit.modLog?.Debug?.Write( $"[OrderSequence_OnUpdate] PositionLockMount- Setting riding unit {targetActor.DisplayName} position to same as carrier unit {__instance.owningActor.DisplayName}"); @@ -2263,6 +2263,18 @@ public static void Postfix(OrderSequence __instance) ModState.CachedUnitCoordinates[__instance.owningActor.GUID] = __instance.owningActor.CurrentPosition; } } + + if (__instance.owningActor.IsSwarmingUnit()) + { + var carrier = combat.FindActorByGUID(ModState.PositionLockSwarm[__instance.owningActor.GUID]); + if (carrier == null) return; + __instance.owningActor.TeleportActorNoResetPathing(carrier.CurrentPosition); + __instance.owningActor.MountedEvasion(__instance.owningActor); + ModInit.modLog?.Debug?.Write( + $"[OrderSequence_OnUpdate] PositionLockMount- Setting riding unit {__instance.owningActor.DisplayName} position to same as carrier unit {carrier.DisplayName}"); + ModState.CachedUnitCoordinates[__instance.owningActor.GUID] = carrier.CurrentPosition; + + } } } @@ -3224,7 +3236,7 @@ public static void Postfix(TurnDirector __instance) { var pos = custMech.CurrentPosition + Vector3.up * custMech.custGameRep.HeightController.CurrentHeight; - squad.TeleportActorVisual(pos); + squad.TeleportActorNoResetPathing(pos); } } } diff --git a/StrategicOperations/StrategicOperations/StrategicOperations.csproj b/StrategicOperations/StrategicOperations/StrategicOperations.csproj index d9f960a..d6a99c0 100644 --- a/StrategicOperations/StrategicOperations/StrategicOperations.csproj +++ b/StrategicOperations/StrategicOperations/StrategicOperations.csproj @@ -33,8 +33,8 @@ Unsafe - 3.1.2.3 - 3.1.2.3 + 3.1.2.4 + 3.1.2.4 @@ -55,11 +55,15 @@ - + $(StrategicOperationsModPath)\..\IRBTModUtils\IRBTModUtils.dll False - + + $(StrategicOperationsModPath)\..\CBTBehaviorsEnhanced\CBTBehaviorsEnhanced.dll + False + + $(StrategicOperationsModPath)\..\CustomComponents\CustomComponents.dll False