diff --git a/NebulaPatcher/Patches/Dynamic/SkillSystem_Common_Patch.cs b/NebulaPatcher/Patches/Dynamic/SkillSystem_Common_Patch.cs index e9631d518..cc51d0f1e 100644 --- a/NebulaPatcher/Patches/Dynamic/SkillSystem_Common_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/SkillSystem_Common_Patch.cs @@ -33,13 +33,14 @@ public static bool GeneralShieldBurst_Prefix(ref GeneralShieldBurst __instance, return false; } - static void SwtichPlayerState(int playerId) + static void SwitchPlayerState(int playerId) { if (!Multiplayer.Session.Combat.IndexByPlayerId.TryGetValue(playerId, out var index)) return; ref var playerData = ref Multiplayer.Session.Combat.Players[index]; var skillSystem = GameMain.data.spaceSector.skillSystem; skillSystem.mecha = playerData.mecha; + skillSystem.playerAlive = playerData.isAlive; skillSystem.playerSkillTargetL = playerData.skillTargetL; skillSystem.playerSkillTargetULast = playerData.skillTargetULast; skillSystem.playerSkillTargetU = playerData.skillTargetU; @@ -49,13 +50,14 @@ static void SwtichPlayerState(int playerId) skillSystem.playerSkillCastRightU = playerData.skillTargetU; } - static void SwtichTargetPlayerWithCollider(int playerId) + static void SwitchTargetPlayerWithCollider(int playerId) { if (!Multiplayer.Session.Combat.IndexByPlayerId.TryGetValue(playerId, out var index)) return; ref var playerData = ref Multiplayer.Session.Combat.Players[index]; var skillSystem = GameMain.data.spaceSector.skillSystem; skillSystem.mecha = playerData.mecha; + skillSystem.playerAlive = playerData.isAlive; skillSystem.playerSkillTargetL = playerData.skillTargetL; skillSystem.playerSkillTargetULast = playerData.skillTargetULast; skillSystem.playerSkillTargetU = playerData.skillTargetU; @@ -66,8 +68,8 @@ static void SwtichTargetPlayerWithCollider(int playerId) public static void GeneralExpImpProjectile_Prefix(ref GeneralExpImpProjectile __instance) { if (!Multiplayer.IsActive) return; - if (__instance.caster.type == ETargetType.Player) SwtichPlayerState(__instance.caster.id); - if (__instance.target.type == ETargetType.Player) SwtichTargetPlayerWithCollider(__instance.target.id); + if (__instance.caster.type == ETargetType.Player) SwitchPlayerState(__instance.caster.id); + if (__instance.target.type == ETargetType.Player) SwitchTargetPlayerWithCollider(__instance.target.id); } [HarmonyPrefix] @@ -75,8 +77,8 @@ public static void GeneralExpImpProjectile_Prefix(ref GeneralExpImpProjectile __ public static void GeneralProjectile_Prefix(ref GeneralMissile __instance) { if (!Multiplayer.IsActive) return; - if (__instance.caster.type == ETargetType.Player) SwtichPlayerState(__instance.caster.id); - if (__instance.target.type == ETargetType.Player) SwtichTargetPlayerWithCollider(__instance.target.id); + if (__instance.caster.type == ETargetType.Player) SwitchPlayerState(__instance.caster.id); + if (__instance.target.type == ETargetType.Player) SwitchTargetPlayerWithCollider(__instance.target.id); } [HarmonyPrefix] @@ -84,8 +86,8 @@ public static void GeneralProjectile_Prefix(ref GeneralMissile __instance) public static void GeneralProjectile_Prefix(ref GeneralProjectile __instance) { if (!Multiplayer.IsActive) return; - if (__instance.caster.type == ETargetType.Player) SwtichPlayerState(__instance.caster.id); - if (__instance.target.type == ETargetType.Player) SwtichTargetPlayerWithCollider(__instance.target.id); + if (__instance.caster.type == ETargetType.Player) SwitchPlayerState(__instance.caster.id); + if (__instance.target.type == ETargetType.Player) SwitchTargetPlayerWithCollider(__instance.target.id); } [HarmonyPrefix] @@ -93,8 +95,8 @@ public static void GeneralProjectile_Prefix(ref GeneralProjectile __instance) public static void LocalGeneralProjectile_Prefix(ref LocalGeneralProjectile __instance) { if (!Multiplayer.IsActive) return; - if (__instance.caster.type == ETargetType.Player) SwtichPlayerState(__instance.caster.id); - if (__instance.target.type == ETargetType.Player) SwtichTargetPlayerWithCollider(__instance.target.id); + if (__instance.caster.type == ETargetType.Player) SwitchPlayerState(__instance.caster.id); + if (__instance.target.type == ETargetType.Player) SwitchTargetPlayerWithCollider(__instance.target.id); } [HarmonyPrefix] @@ -102,8 +104,8 @@ public static void LocalGeneralProjectile_Prefix(ref LocalGeneralProjectile __in public static void LocalLaserContinuous_Prefix(ref LocalLaserContinuous __instance) { if (!Multiplayer.IsActive) return; - if (__instance.caster.type == ETargetType.Player) SwtichPlayerState(__instance.caster.id); - if (__instance.target.type == ETargetType.Player) SwtichPlayerState(__instance.target.id); + if (__instance.caster.type == ETargetType.Player) SwitchPlayerState(__instance.caster.id); + if (__instance.target.type == ETargetType.Player) SwitchPlayerState(__instance.target.id); } [HarmonyPrefix] @@ -111,8 +113,8 @@ public static void LocalLaserContinuous_Prefix(ref LocalLaserContinuous __instan public static void LocalLaserOneShot_Prefix(ref LocalLaserOneShot __instance) { if (!Multiplayer.IsActive) return; - if (__instance.caster.type == ETargetType.Player) SwtichPlayerState(__instance.caster.id); - if (__instance.target.type == ETargetType.Player) SwtichPlayerState(__instance.target.id); + if (__instance.caster.type == ETargetType.Player) SwitchPlayerState(__instance.caster.id); + if (__instance.target.type == ETargetType.Player) SwitchPlayerState(__instance.target.id); } [HarmonyPrefix] @@ -120,7 +122,7 @@ public static void LocalLaserOneShot_Prefix(ref LocalLaserOneShot __instance) public static void LocalCannonade_Prefix(ref LocalCannonade __instance) { if (!Multiplayer.IsActive) return; - if (__instance.caster.type == ETargetType.Player) SwtichPlayerState(__instance.caster.id); + if (__instance.caster.type == ETargetType.Player) SwitchPlayerState(__instance.caster.id); } [HarmonyPrefix] @@ -128,8 +130,8 @@ public static void LocalCannonade_Prefix(ref LocalCannonade __instance) public static void SpaceLaserOneShot_Prefix(ref SpaceLaserOneShot __instance) { if (!Multiplayer.IsActive) return; - if (__instance.caster.type == ETargetType.Player) SwtichPlayerState(__instance.caster.id); - if (__instance.target.type == ETargetType.Player) SwtichPlayerState(__instance.target.id); + if (__instance.caster.type == ETargetType.Player) SwitchPlayerState(__instance.caster.id); + if (__instance.target.type == ETargetType.Player) SwitchPlayerState(__instance.target.id); } [HarmonyPrefix] @@ -137,7 +139,7 @@ public static void SpaceLaserOneShot_Prefix(ref SpaceLaserOneShot __instance) public static void SpaceLaserSweep_Prefix(ref SpaceLaserSweep __instance) { if (!Multiplayer.IsActive) return; - if (__instance.caster.type == ETargetType.Player) SwtichPlayerState(__instance.caster.id); - if ((__instance.mask & ETargetTypeMask.Player) != 0) SwtichTargetPlayerWithCollider(Multiplayer.Session.LocalPlayer.Id); + if (__instance.caster.type == ETargetType.Player) SwitchPlayerState(__instance.caster.id); + if ((__instance.mask & ETargetTypeMask.Player) != 0) SwitchTargetPlayerWithCollider(Multiplayer.Session.LocalPlayer.Id); } } diff --git a/NebulaPatcher/Patches/Dynamic/SkillSystem_Patch.cs b/NebulaPatcher/Patches/Dynamic/SkillSystem_Patch.cs index ac4db07ca..e35927ea6 100644 --- a/NebulaPatcher/Patches/Dynamic/SkillSystem_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/SkillSystem_Patch.cs @@ -49,6 +49,17 @@ public static bool Import_Prefix(SkillSystem __instance, BinaryReader r) return false; } + [HarmonyPostfix] + [HarmonyPatch(nameof(SkillSystem.CollectPlayerStates))] + public static void CollectPlayerStates_Postfix(SkillSystem __instance) + { + if (!Multiplayer.IsActive) return; + + // Set those flags to false so AddSpaceEnemyHatred can add threat correctly for client's skill in host + __instance.playerIsSailing = false; + __instance.playerIsWarping = false; + } + [HarmonyPostfix] [HarmonyPatch(nameof(SkillSystem.AfterTick))] public static void AfterTick_Postfix(SkillSystem __instance)