diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 11fa4bf835..dab836227a 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -5267,6 +5267,9 @@ namespace CalamityMod.CalPlayer if (titanHeartSet && StealthStrikeAvailable() && rogue) knockback *= TitanHeartMask.StealthStrikeKnockbackMult; + + Player.GetKnockback() += 0.2f; + //Player.GetKnockback().ApplyTo(1); } #endregion diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index 2276e7f805..ae18de7e06 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -249,7 +249,7 @@ namespace CalamityMod.CalPlayer if (proj.IsMinionOrSentryRelated) center = proj.Center; Vector2 launchVel = Utils.DirectionTo(center, target.Center); - target.MoveNPC(launchVel, proj.knockBack, true); + target.MoveNPC(launchVel, proj.knockBack, true, Player); } if (moscowMule || bloodyMary) diff --git a/Items/Accessories/ShieldoftheOcean.cs b/Items/Accessories/ShieldoftheOcean.cs index 02daf35a01..00ef2c412f 100644 --- a/Items/Accessories/ShieldoftheOcean.cs +++ b/Items/Accessories/ShieldoftheOcean.cs @@ -78,11 +78,11 @@ namespace CalamityMod.Items.Accessories // If the NPC can be moved, violently shove them away. Make them susceptible to fall damage on empowered parries. // Otherwise, simply deal a large amount of damage to them if empowered. - if (npc.CanBeMoved(true)) + if (npc.CanBeMoved()) { // The NPC has to actually have its velocity changed, because TileCollisionHarmNPC only changes its position. Not confusing at all! Vector2 shoveVelocity = Utils.DirectionTo(player.Center, npc.Center) * (Main.zenithWorld ? 35f : 12.5f) - Vector2.UnitY * 6f; - npc.MoveNPC(Vector2.Normalize(shoveVelocity), shoveVelocity.Length(), true); + npc.MoveNPC(Vector2.Normalize(shoveVelocity), shoveVelocity.Length(), true, player); int scaledFallDamage = CalamityUtils.ScaleWithDifficulty(ShoveFallBaseDamage); var flungNPC = npc.GetGlobalNPC(); diff --git a/NPCs/Abyss/CannonballJellyfish.cs b/NPCs/Abyss/CannonballJellyfish.cs index 4ac27bd126..f24782ec3c 100644 --- a/NPCs/Abyss/CannonballJellyfish.cs +++ b/NPCs/Abyss/CannonballJellyfish.cs @@ -17,6 +17,7 @@ using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.Abyss { + [HeavyKnockbackWhitelisted] public class CannonballJellyfish : ModNPC { public bool hasBeenHit = false; diff --git a/NPCs/Abyss/ChaoticPuffer.cs b/NPCs/Abyss/ChaoticPuffer.cs index 2ef44a8f59..407135ec7b 100644 --- a/NPCs/Abyss/ChaoticPuffer.cs +++ b/NPCs/Abyss/ChaoticPuffer.cs @@ -15,6 +15,7 @@ using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.Abyss { + [HeavyKnockbackWhitelisted] public class ChaoticPuffer : ModNPC { public bool puffedUp = false; diff --git a/NPCs/Abyss/ColossalSquid.cs b/NPCs/Abyss/ColossalSquid.cs index 951075b079..dfe2e0cab1 100644 --- a/NPCs/Abyss/ColossalSquid.cs +++ b/NPCs/Abyss/ColossalSquid.cs @@ -19,6 +19,7 @@ using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.Abyss { + [HeavyKnockbackWhitelisted] public class ColossalSquid : ModNPC { public bool hasBeenHit = false; diff --git a/NPCs/Abyss/EidolonWyrmHead.cs b/NPCs/Abyss/EidolonWyrmHead.cs index 06341b7b05..dae263984c 100644 --- a/NPCs/Abyss/EidolonWyrmHead.cs +++ b/NPCs/Abyss/EidolonWyrmHead.cs @@ -26,6 +26,7 @@ using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.Abyss { [LongDistanceNetSync] + [HeavyKnockbackWhitelisted] public class EidolonWyrmHead : ModNPC { private Vector2 patrolSpot = Vector2.Zero; diff --git a/NPCs/Abyss/GulperEelHead.cs b/NPCs/Abyss/GulperEelHead.cs index b3db09830a..24d56ebdb6 100644 --- a/NPCs/Abyss/GulperEelHead.cs +++ b/NPCs/Abyss/GulperEelHead.cs @@ -17,6 +17,7 @@ using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.Abyss { [LongDistanceNetSync] + [HeavyKnockbackWhitelisted] public class GulperEelHead : ModNPC { private Vector2 patrolSpot = Vector2.Zero; diff --git a/NPCs/Abyss/MirageJelly.cs b/NPCs/Abyss/MirageJelly.cs index 13dcc29c85..963c4580e0 100644 --- a/NPCs/Abyss/MirageJelly.cs +++ b/NPCs/Abyss/MirageJelly.cs @@ -16,6 +16,7 @@ using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.Abyss { + [HeavyKnockbackWhitelisted] public class MirageJelly : ModNPC { private bool teleporting = false; diff --git a/NPCs/Abyss/OarfishHead.cs b/NPCs/Abyss/OarfishHead.cs index fec514fc15..3a49ef77ef 100644 --- a/NPCs/Abyss/OarfishHead.cs +++ b/NPCs/Abyss/OarfishHead.cs @@ -16,6 +16,7 @@ using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.Abyss { [LongDistanceNetSync] + [HeavyKnockbackWhitelisted] public class OarfishHead : ModNPC { private Vector2 patrolSpot = Vector2.Zero; diff --git a/NPCs/Abyss/ReaperShark.cs b/NPCs/Abyss/ReaperShark.cs index cce3312e48..ceee4b8ef8 100644 --- a/NPCs/Abyss/ReaperShark.cs +++ b/NPCs/Abyss/ReaperShark.cs @@ -20,6 +20,7 @@ using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.Abyss { + [HeavyKnockbackWhitelisted] public class ReaperShark : ModNPC { public static Asset ManTexture; diff --git a/NPCs/Abyss/SlabCrab.cs b/NPCs/Abyss/SlabCrab.cs index 99d5a112fe..55b402b4df 100644 --- a/NPCs/Abyss/SlabCrab.cs +++ b/NPCs/Abyss/SlabCrab.cs @@ -18,6 +18,7 @@ using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.Abyss { + [HeavyKnockbackWhitelisted] public class SlabCrab : ModNPC { enum AIState diff --git a/NPCs/AcidRain/BloodwormFleeing.cs b/NPCs/AcidRain/BloodwormFleeing.cs index 8670ed3870..9da8ac1562 100644 --- a/NPCs/AcidRain/BloodwormFleeing.cs +++ b/NPCs/AcidRain/BloodwormFleeing.cs @@ -6,6 +6,7 @@ using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.NPCs.AcidRain { + [HeavyKnockbackWhitelisted] public class BloodwormFleeing : ModNPC { public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.BloodwormNormal.DisplayName"); diff --git a/NPCs/AcidRain/BloodwormNormal.cs b/NPCs/AcidRain/BloodwormNormal.cs index ad723affaa..718537c5ee 100644 --- a/NPCs/AcidRain/BloodwormNormal.cs +++ b/NPCs/AcidRain/BloodwormNormal.cs @@ -10,6 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AcidRain { + [HeavyKnockbackWhitelisted] public class BloodwormNormal : ModNPC { public override void SetStaticDefaults() diff --git a/NPCs/AcidRain/CragmawMire.cs b/NPCs/AcidRain/CragmawMire.cs index a91b3a9793..92368654ad 100644 --- a/NPCs/AcidRain/CragmawMire.cs +++ b/NPCs/AcidRain/CragmawMire.cs @@ -23,6 +23,7 @@ using Terraria.WorldBuilding; namespace CalamityMod.NPCs.AcidRain { [AutoloadBossHead] + [HeavyKnockbackWhitelisted] public class CragmawMire : ModNPC { public enum CragmawAttackState diff --git a/NPCs/AcidRain/FlakCrab.cs b/NPCs/AcidRain/FlakCrab.cs index a2f6a64262..cf6b88cc32 100644 --- a/NPCs/AcidRain/FlakCrab.cs +++ b/NPCs/AcidRain/FlakCrab.cs @@ -15,6 +15,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AcidRain { + [HeavyKnockbackWhitelisted] public class FlakCrab : ModNPC { public Player Target => Main.player[NPC.target]; diff --git a/NPCs/AcidRain/GammaSlime.cs b/NPCs/AcidRain/GammaSlime.cs index c3bae2cc77..55f41a9b93 100644 --- a/NPCs/AcidRain/GammaSlime.cs +++ b/NPCs/AcidRain/GammaSlime.cs @@ -15,6 +15,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AcidRain { + [HeavyKnockbackWhitelisted] public class GammaSlime : ModNPC { public float DustAngleMultiplier1; diff --git a/NPCs/AcidRain/Mauler.cs b/NPCs/AcidRain/Mauler.cs index 51ed39b3da..fb3fe345bf 100644 --- a/NPCs/AcidRain/Mauler.cs +++ b/NPCs/AcidRain/Mauler.cs @@ -21,6 +21,7 @@ using Terraria.WorldBuilding; namespace CalamityMod.NPCs.AcidRain { [AutoloadBossHead] + [HeavyKnockbackWhitelisted] public class Mauler : ModNPC { // TODO -- Potentially add another attack in higher difficulty modes at some point? diff --git a/NPCs/AcidRain/NuclearTerror.cs b/NPCs/AcidRain/NuclearTerror.cs index 7d6d04049f..a5bf709271 100644 --- a/NPCs/AcidRain/NuclearTerror.cs +++ b/NPCs/AcidRain/NuclearTerror.cs @@ -19,6 +19,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AcidRain { [AutoloadBossHead] + [HeavyKnockbackWhitelisted] public class NuclearTerror : ModNPC { public enum SpecialAttackState diff --git a/NPCs/AcidRain/SulphurousSkater.cs b/NPCs/AcidRain/SulphurousSkater.cs index 51a9914263..e34dfe714d 100644 --- a/NPCs/AcidRain/SulphurousSkater.cs +++ b/NPCs/AcidRain/SulphurousSkater.cs @@ -18,6 +18,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AcidRain { + [HeavyKnockbackWhitelisted] public class SulphurousSkater : ModNPC { public bool Flying = false; diff --git a/NPCs/Astral/AstralachneaWall.cs b/NPCs/Astral/AstralachneaWall.cs index 9f9a0c9703..60823673ec 100644 --- a/NPCs/Astral/AstralachneaWall.cs +++ b/NPCs/Astral/AstralachneaWall.cs @@ -19,6 +19,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Astral { + [HeavyKnockbackWhitelisted] public class AstralachneaWall : ModNPC { public static Asset glowmask; diff --git a/NPCs/Astral/SightseerSpitter.cs b/NPCs/Astral/SightseerSpitter.cs index d3c9e0f44a..acb2a97565 100644 --- a/NPCs/Astral/SightseerSpitter.cs +++ b/NPCs/Astral/SightseerSpitter.cs @@ -16,6 +16,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Astral { + [HeavyKnockbackWhitelisted] public class SightseerSpitter : ModNPC { public static Asset glowmask; diff --git a/NPCs/AstrumAureus/AureusSpawn.cs b/NPCs/AstrumAureus/AureusSpawn.cs index 9d20520ac4..5b3052c3ce 100644 --- a/NPCs/AstrumAureus/AureusSpawn.cs +++ b/NPCs/AstrumAureus/AureusSpawn.cs @@ -18,6 +18,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AstrumAureus { + [HeavyKnockbackWhitelisted] public class AureusSpawn : ModNPC { public static Asset GlowTexture; diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 163b7a2a5b..c5c3f455b8 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -3182,7 +3182,7 @@ namespace CalamityMod.NPCs SoundEngine.PlaySound(fullPower with { Volume = 0.7f, Pitch = 0.7f }, npc.Center); warbannerBurnStacks++; } - if (warbannerBurnIntensity > 2.5f && npc.CanBeMoved(true)) + if (warbannerBurnIntensity > 2.5f && npc.CanBeMoved()) { npc.velocity *= 1f - 0.25f * Utils.GetLerpValue(2.5f, 3, warbannerBurnIntensity); if (npc.velocity.Length() > 5 && warbannerBurnIntensity > 2.85f) // Repel leaping enemies @@ -3358,7 +3358,7 @@ namespace CalamityMod.NPCs pearlAuraOwner = -1; } - if (demonSwordImpales > 0 && npc.CanBeMoved(true)) + if (demonSwordImpales > 0 && npc.CanBeMoved()) { npc.velocity *= Utils.Remap(demonSwordImpales, 1, 5, 0.95f, 0.3f, true); if (impalePacketTimer > 30) // There's probably a better solution, but this is the best for now diff --git a/NPCs/CalamityHeavyKnockbackWhitelist.cs b/NPCs/CalamityHeavyKnockbackWhitelist.cs new file mode 100644 index 0000000000..00140543d2 --- /dev/null +++ b/NPCs/CalamityHeavyKnockbackWhitelist.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using CalamityMod.Balancing; +using CalamityMod.Items.Accessories; +using CalamityMod.Systems.Collections; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.NPCs +{ + public sealed class CalamityHeavyKnockbackWhitelist : GlobalNPC + { + // General rule of thumb I used for this is to not put it on anything that is a stationary entity (EX: Tesla Turrets, Antlions, Hive Cysts) + // No putting it on any bosses, though boss minions are fair game when applicable (no stuff like Scal hearts obviously, sending them into the void would be bad) + internal static HashSet whitelistNPC; + public override void Load() + { + whitelistNPC = new(); + } + public override void Unload() + { + whitelistNPC?.Clear(); + whitelistNPC = null; + } + public override void SetStaticDefaults() + { + // Add vanilla enemies to the whitelist + whitelistNPC.Add(NPCID.AncientCultistSquidhead); + whitelistNPC.Add(NPCID.DesertDjinn); + whitelistNPC.Add(NPCID.DD2DrakinT2); + whitelistNPC.Add(NPCID.DD2DrakinT3); + whitelistNPC.Add(NPCID.DungeonGuardian); + whitelistNPC.Add(NPCID.GrayGrunt); + whitelistNPC.Add(NPCID.HeadlessHorseman); + whitelistNPC.Add(NPCID.LihzahrdCrawler); + whitelistNPC.Add(NPCID.MartianProbe); + whitelistNPC.Add(NPCID.MartianWalker); + whitelistNPC.Add(NPCID.Paladin); + whitelistNPC.Add(NPCID.PirateCaptain); + whitelistNPC.Add(NPCID.ShadowFlameApparition); + whitelistNPC.Add(NPCID.ThePossessed); + whitelistNPC.Add(NPCID.EyeballFlyingFish); + whitelistNPC.Add(NPCID.Yeti); + whitelistNPC.Add(NPCID.ZombieMerman); + whitelistNPC.Add(NPCID.FungiBulb); + whitelistNPC.Add(NPCID.GiantFungiBulb); + whitelistNPC.Add(NPCID.ManEater); + whitelistNPC.Add(NPCID.Snatcher); + whitelistNPC.Add(NPCID.BloodEelHead); + whitelistNPC.Add(NPCID.BoneSerpentHead); + whitelistNPC.Add(NPCID.DevourerHead); + whitelistNPC.Add(NPCID.DiggerHead); + whitelistNPC.Add(NPCID.DuneSplicerHead); + whitelistNPC.Add(NPCID.GiantWormHead); + whitelistNPC.Add(NPCID.LeechHead); + whitelistNPC.Add(NPCID.StardustWormHead); + whitelistNPC.Add(NPCID.CultistDragonHead); + whitelistNPC.Add(NPCID.AncientCultistSquidhead); + whitelistNPC.Add(NPCID.TombCrawlerHead); + whitelistNPC.Add(NPCID.TruffleWormDigger); + whitelistNPC.Add(NPCID.SeekerHead); + whitelistNPC.Add(NPCID.WyvernHead); + whitelistNPC.Add(NPCID.Creeper); // Here because they gain KB immunity in multiplayer + whitelistNPC.Add(NPCID.TheHungry); // Here because they gain KB immunity in multiplayer + whitelistNPC.Add(NPCID.TheHungryII); // Here because they gain KB immunity in multiplayer + whitelistNPC.Add(NPCID.DD2DarkMageT1); + whitelistNPC.Add(NPCID.DD2DarkMageT3); + whitelistNPC.Add(NPCID.DD2OgreT2); + whitelistNPC.Add(NPCID.DD2OgreT3); + whitelistNPC.Add(NPCID.MourningWood); + whitelistNPC.Add(NPCID.Pumpking); + whitelistNPC.Add(NPCID.Everscream); + whitelistNPC.Add(NPCID.SantaNK1); + whitelistNPC.Add(NPCID.IceQueen); + whitelistNPC.Add(NPCID.MartianSaucerCore); + whitelistNPC.Add(NPCID.Sharkron); + whitelistNPC.Add(NPCID.Sharkron2); + // Below are enemies Calamity gives KB immunity, but that aren't KB immune in vanilla + whitelistNPC.Add(NPCID.Mothron); + whitelistNPC.Add(NPCID.BigMimicCorruption); + whitelistNPC.Add(NPCID.BigMimicCrimson); + whitelistNPC.Add(NPCID.BigMimicHallow); + whitelistNPC.Add(NPCID.BigMimicJungle); + whitelistNPC.Add(NPCID.SolarCorite); + whitelistNPC.Add(NPCID.CrimsonAxe); + whitelistNPC.Add(NPCID.CursedHammer); + whitelistNPC.Add(NPCID.EnchantedSword); + whitelistNPC.Add(NPCID.GiantTortoise); + whitelistNPC.Add(NPCID.IceTortoise); + whitelistNPC.Add(NPCID.GoblinSummoner); + whitelistNPC.Add(NPCID.Butcher); + + var npcs = GetContent(); + foreach (var npc in npcs) + { + try + { + var type = npc.GetType(); + var whitelisted = type.GetCustomAttribute(); + if (whitelisted != null) + { + int npcType = npc.Type; + whitelistNPC.Add(npcType); + } + } + catch (Exception e) + { + CalamityMod.Log.Error($"Exception thrown while evaluating type \"{npc.FullName}\": {e}"); + } + } + } + } +} diff --git a/NPCs/Crags/HeatSpirit.cs b/NPCs/Crags/HeatSpirit.cs index cfc7c0469f..6b1b8c374d 100644 --- a/NPCs/Crags/HeatSpirit.cs +++ b/NPCs/Crags/HeatSpirit.cs @@ -12,6 +12,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.Crags { + [HeavyKnockbackWhitelisted] public class HeatSpirit : ModNPC { public override void SetStaticDefaults() diff --git a/NPCs/DraedonLabThings/Androomba.cs b/NPCs/DraedonLabThings/Androomba.cs index fc60264b5f..09230077a7 100644 --- a/NPCs/DraedonLabThings/Androomba.cs +++ b/NPCs/DraedonLabThings/Androomba.cs @@ -13,6 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.DraedonLabThings { + [HeavyKnockbackWhitelisted] public class Androomba : ModNPC { diff --git a/NPCs/DraedonLabThings/RepairUnitCritter.cs b/NPCs/DraedonLabThings/RepairUnitCritter.cs index 4aebb02ae2..a3c7bcb9c1 100644 --- a/NPCs/DraedonLabThings/RepairUnitCritter.cs +++ b/NPCs/DraedonLabThings/RepairUnitCritter.cs @@ -15,6 +15,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.DraedonLabThings { + [HeavyKnockbackWhitelisted] public class RepairUnitCritter : ModNPC { public enum BehaviorState diff --git a/NPCs/GreatSandShark/GreatSandShark.cs b/NPCs/GreatSandShark/GreatSandShark.cs index 42af41cb27..42d7441b6c 100644 --- a/NPCs/GreatSandShark/GreatSandShark.cs +++ b/NPCs/GreatSandShark/GreatSandShark.cs @@ -20,6 +20,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.GreatSandShark { [AutoloadBossHead] + [HeavyKnockbackWhitelisted] public class GreatSandShark : ModNPC { private bool resetAI = false; diff --git a/NPCs/HeavyKnockbackWhitelistedAttribute.cs b/NPCs/HeavyKnockbackWhitelistedAttribute.cs new file mode 100644 index 0000000000..0bc40aa705 --- /dev/null +++ b/NPCs/HeavyKnockbackWhitelistedAttribute.cs @@ -0,0 +1,13 @@ +using System; + +namespace CalamityMod.NPCs +{ + /// + /// This attribute puts an NPC into the heavy knockback whitelist + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] + public sealed class HeavyKnockbackWhitelistedAttribute : Attribute + { + + } +} diff --git a/NPCs/NormalNPCs/AuroraSpirit.cs b/NPCs/NormalNPCs/AuroraSpirit.cs index 95e4beec0b..d013f9f032 100644 --- a/NPCs/NormalNPCs/AuroraSpirit.cs +++ b/NPCs/NormalNPCs/AuroraSpirit.cs @@ -9,6 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { + [HeavyKnockbackWhitelisted] public class AuroraSpirit : ModNPC { public override void SetStaticDefaults() diff --git a/NPCs/NormalNPCs/PlanterasFreeTentacle.cs b/NPCs/NormalNPCs/PlanterasFreeTentacle.cs index c4fa0d8395..07040968de 100644 --- a/NPCs/NormalNPCs/PlanterasFreeTentacle.cs +++ b/NPCs/NormalNPCs/PlanterasFreeTentacle.cs @@ -8,6 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { + [HeavyKnockbackWhitelisted] public class PlanterasFreeTentacle : ModNPC { public override string Texture => $"Terraria/Images/NPC_{NPCID.PlanterasTentacle}"; diff --git a/NPCs/NormalNPCs/ScornEater.cs b/NPCs/NormalNPCs/ScornEater.cs index 2891aa5e74..dffd4e8a18 100644 --- a/NPCs/NormalNPCs/ScornEater.cs +++ b/NPCs/NormalNPCs/ScornEater.cs @@ -12,6 +12,7 @@ using Terraria.ModLoader; using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.NormalNPCs { + [HeavyKnockbackWhitelisted] public class ScornEater : ModNPC { diff --git a/NPCs/OldDuke/SulphurousSharkron.cs b/NPCs/OldDuke/SulphurousSharkron.cs index dc51b1a0f1..4592d3b4b4 100644 --- a/NPCs/OldDuke/SulphurousSharkron.cs +++ b/NPCs/OldDuke/SulphurousSharkron.cs @@ -15,6 +15,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.OldDuke { + [HeavyKnockbackWhitelisted] public class SulphurousSharkron : ModNPC { public override void SetStaticDefaults() diff --git a/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs b/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs index 8cd56e8f01..e9c9606af2 100644 --- a/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs +++ b/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs @@ -14,6 +14,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.PlaguebringerGoliath { + [HeavyKnockbackWhitelisted] public class PlagueHomingMissile : ModNPC { public static Asset GlowTexture; diff --git a/NPCs/Signus/CosmicLantern.cs b/NPCs/Signus/CosmicLantern.cs index 33d6c79feb..4bcda5bc2f 100644 --- a/NPCs/Signus/CosmicLantern.cs +++ b/NPCs/Signus/CosmicLantern.cs @@ -12,6 +12,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.Signus { + [HeavyKnockbackWhitelisted] public class CosmicLantern : ModNPC { public static Asset GlowTexture; diff --git a/Projectiles/DraedonsArsenal/AugerPull.cs b/Projectiles/DraedonsArsenal/AugerPull.cs index ce365ce951..4abb72e134 100644 --- a/Projectiles/DraedonsArsenal/AugerPull.cs +++ b/Projectiles/DraedonsArsenal/AugerPull.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal for (int i = 0; i < Main.maxNPCs; i++) { NPC target = Main.npc[i]; - if (target != null && target.CanBeMoved(true) && Collision.CanHit(Projectile.Center, 1, 1, target.Center, 1, 1) && Vector2.Distance(target.Center, Projectile.Center) < 650) + if (target != null && target.CanBeMoved() && Collision.CanHit(Projectile.Center, 1, 1, target.Center, 1, 1) && Vector2.Distance(target.Center, Projectile.Center) < 650) { Vector2 moveDir = target.Center.DirectionTo(Projectile.Center).SafeNormalize(Vector2.UnitX); target.velocity = moveDir; @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal for (int i = 0; i < Main.maxNPCs; i++) { NPC target = Main.npc[i]; - if (target != null && target.CanBeMoved(true) && Collision.CanHit(Projectile.Center, 1, 1, target.Center, 1, 1)) + if (target != null && target.CanBeMoved() && Collision.CanHit(Projectile.Center, 1, 1, target.Center, 1, 1)) { if (Vector2.Distance(target.Center, Projectile.Center) > 15 && Vector2.Distance(target.Center, Projectile.Center) < 300) { diff --git a/Projectiles/DraedonsArsenal/AugerSlash.cs b/Projectiles/DraedonsArsenal/AugerSlash.cs index ac72757579..dfe7bc00b1 100644 --- a/Projectiles/DraedonsArsenal/AugerSlash.cs +++ b/Projectiles/DraedonsArsenal/AugerSlash.cs @@ -81,7 +81,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Vector2 launchVel = Projectile.velocity.SafeNormalize(Vector2.UnitX); float launchPower = (Projectile.ai[2] == 5 ? 35 : 14); - target.MoveNPC(launchVel, launchPower, true); + target.MoveNPC(launchVel, launchPower, true, Owner); if (Projectile.ai[2] == 5) modifiers.SetCrit(); diff --git a/Projectiles/DraedonsArsenal/CountermeasurePalmBlast.cs b/Projectiles/DraedonsArsenal/CountermeasurePalmBlast.cs index 295d12422c..07263d5cca 100644 --- a/Projectiles/DraedonsArsenal/CountermeasurePalmBlast.cs +++ b/Projectiles/DraedonsArsenal/CountermeasurePalmBlast.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { Vector2 launchVel = Projectile.velocity.SafeNormalize(Vector2.UnitX); float launchPower = 25; - targeted.MoveNPC(launchVel, launchPower, true); + targeted.MoveNPC(launchVel, launchPower, true, Owner); } time++; } @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Vector2 launchVel = Projectile.velocity.SafeNormalize(Vector2.UnitX); float launchPower = 40; - target.MoveNPC(launchVel, launchPower, true); + target.MoveNPC(launchVel, launchPower, true, Owner); } public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/DraedonsArsenal/NidhoggExplosion.cs b/Projectiles/DraedonsArsenal/NidhoggExplosion.cs index 428ab220d0..dcbec391c1 100644 --- a/Projectiles/DraedonsArsenal/NidhoggExplosion.cs +++ b/Projectiles/DraedonsArsenal/NidhoggExplosion.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal for (int i = 0; i < Main.maxNPCs; i++) { NPC target = Main.npc[i]; - if (target != null && target.CanBeMoved(true)) + if (target != null && target.CanBeMoved()) { if (Vector2.Distance(target.Center, Projectile.Center) > 15 && Vector2.Distance(target.Center, Projectile.Center) < 500) { diff --git a/Projectiles/DraedonsArsenal/NidhoggRailgunBigShot.cs b/Projectiles/DraedonsArsenal/NidhoggRailgunBigShot.cs index a05b781b79..7d14fdce6e 100644 --- a/Projectiles/DraedonsArsenal/NidhoggRailgunBigShot.cs +++ b/Projectiles/DraedonsArsenal/NidhoggRailgunBigShot.cs @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Vector2 launchVel = Projectile.velocity.SafeNormalize(Vector2.UnitX); float launchPower = 20; - target.MoveNPC(launchVel, launchPower, true); + target.MoveNPC(launchVel, launchPower, true, Owner); } public override void OnKill(int timeLeft) diff --git a/Projectiles/DraedonsArsenal/NidhoggRailgunBlast.cs b/Projectiles/DraedonsArsenal/NidhoggRailgunBlast.cs index ba71ef2c53..bcb44deb3c 100644 --- a/Projectiles/DraedonsArsenal/NidhoggRailgunBlast.cs +++ b/Projectiles/DraedonsArsenal/NidhoggRailgunBlast.cs @@ -52,6 +52,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { + Player Owner = Main.player[Projectile.owner]; Particle spark = new GlowSparkParticle(Projectile.Center, Projectile.velocity, false, 8, MathHelper.Clamp(0.06f - Projectile.numHits * 0.01f, 0f, 0.06f), Effects.ArsenalEffects.ArsenalGaussColor * 0.9f, new Vector2(1f, 0.5f), true, true, 0.9f); GeneralParticleHandler.SpawnParticle(spark); @@ -74,7 +75,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Vector2 launchVel = Projectile.velocity.SafeNormalize(Vector2.UnitX); float launchPower = 6; - target.MoveNPC(launchVel, launchPower, true); + target.MoveNPC(launchVel, launchPower, true, Owner); } public override void OnKill(int timeLeft) diff --git a/Projectiles/DraedonsArsenal/PhalanxSurgeLance.cs b/Projectiles/DraedonsArsenal/PhalanxSurgeLance.cs index 8fcacbe4d0..6e597a6e2b 100644 --- a/Projectiles/DraedonsArsenal/PhalanxSurgeLance.cs +++ b/Projectiles/DraedonsArsenal/PhalanxSurgeLance.cs @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Player Owner = Main.player[Projectile.owner]; float distMult = Utils.GetLerpValue(400, 10, Utils.Distance(target.Center, Projectile.Center), true); Vector2 launchVel = startVel; - target.MoveNPC(launchVel, 10 + 35 * distMult, true); + target.MoveNPC(launchVel, 10 + 35 * distMult, true, Owner); if (Projectile.numHits == 0) { diff --git a/Projectiles/DraedonsArsenal/ShortCircuitExplosion.cs b/Projectiles/DraedonsArsenal/ShortCircuitExplosion.cs index e931f7966f..f9740376b1 100644 --- a/Projectiles/DraedonsArsenal/ShortCircuitExplosion.cs +++ b/Projectiles/DraedonsArsenal/ShortCircuitExplosion.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Ranged Player Owner = Main.player[Projectile.owner]; Vector2 launchVel = Utils.DirectionTo(Owner.Center, target.Center); - target.MoveNPC(launchVel, 12, true); + target.MoveNPC(launchVel, 12, true, Owner); } public override void AI() diff --git a/Projectiles/DraedonsArsenal/ShortCircuitShot.cs b/Projectiles/DraedonsArsenal/ShortCircuitShot.cs index 95c1b5dc0d..ac88bcf212 100644 --- a/Projectiles/DraedonsArsenal/ShortCircuitShot.cs +++ b/Projectiles/DraedonsArsenal/ShortCircuitShot.cs @@ -76,7 +76,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal target.AddBuff(ModContent.BuffType(), 40); Vector2 launchVel = Utils.DirectionTo(Owner.Center, target.Center); - target.MoveNPC(launchVel, 8, false); + target.MoveNPC(launchVel, 8, false, Owner); } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { diff --git a/Projectiles/DraedonsArsenal/VulcanProjectile.cs b/Projectiles/DraedonsArsenal/VulcanProjectile.cs index 8f805e1a94..915998cce8 100644 --- a/Projectiles/DraedonsArsenal/VulcanProjectile.cs +++ b/Projectiles/DraedonsArsenal/VulcanProjectile.cs @@ -60,11 +60,12 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { + Player Owner = Main.player[Projectile.owner]; impactDust(); Vector2 launchVel = Projectile.velocity.SafeNormalize(Vector2.UnitX); float launchPower = 4; - target.MoveNPC(launchVel, launchPower, true); + target.MoveNPC(launchVel, launchPower, true, Owner); } public override void OnKill(int timeLeft) diff --git a/Projectiles/DraedonsArsenal/VulcanSpear.cs b/Projectiles/DraedonsArsenal/VulcanSpear.cs index 55707121f9..c921a059c7 100644 --- a/Projectiles/DraedonsArsenal/VulcanSpear.cs +++ b/Projectiles/DraedonsArsenal/VulcanSpear.cs @@ -128,11 +128,12 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { + Player Owner = Main.player[Projectile.owner]; impactDust(); Vector2 launchVel = Projectile.velocity.SafeNormalize(Vector2.UnitX); float launchPower = 12; - target.MoveNPC(launchVel, launchPower, true); + target.MoveNPC(launchVel, launchPower, true, Owner); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { diff --git a/Projectiles/Magic/FireImplosion.cs b/Projectiles/Magic/FireImplosion.cs index b053d51ba6..aedb225937 100644 --- a/Projectiles/Magic/FireImplosion.cs +++ b/Projectiles/Magic/FireImplosion.cs @@ -98,6 +98,7 @@ namespace CalamityMod.Projectiles.Magic } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { + Player Owner = Main.player[Projectile.owner]; if (frigidFlash) { target.AddBuff(BuffID.OnFire3, 30); @@ -112,7 +113,7 @@ namespace CalamityMod.Projectiles.Magic modifiers.SourceDamage *= damageMult * (frigidFlash ? 0.5f : 1); // Frigidflash explosion are spawned at full power, so their damage is reduced here // The vortex sucks in enemies - target.MoveNPC(-pushVelocity, customKnockback, frigidFlash); + target.MoveNPC(-pushVelocity, customKnockback, frigidFlash, Owner); } public override void OnKill(int timeLeft) { diff --git a/Projectiles/Magic/PhantasmalFuryProj.cs b/Projectiles/Magic/PhantasmalFuryProj.cs index ac35739eca..9c79b761b0 100644 --- a/Projectiles/Magic/PhantasmalFuryProj.cs +++ b/Projectiles/Magic/PhantasmalFuryProj.cs @@ -105,7 +105,7 @@ namespace CalamityMod.Projectiles.Magic Player Owner = Main.player[Projectile.owner]; Vector2 launchVel = (Owner.Center - target.Center).SafeNormalize(Vector2.UnitY) * -10 * (launched ? 0.5f : 1); - target.MoveNPC(launchVel, 10 * (launched ? 0.5f : 1), true); + target.MoveNPC(launchVel, 10 * (launched ? 0.5f : 1), true, Owner); } public override bool? CanHitNPC(NPC target) { diff --git a/Projectiles/Magic/Phantom.cs b/Projectiles/Magic/Phantom.cs index eb3af39916..1b12a7f910 100644 --- a/Projectiles/Magic/Phantom.cs +++ b/Projectiles/Magic/Phantom.cs @@ -107,7 +107,7 @@ namespace CalamityMod.Projectiles.Magic Player Owner = Main.player[Projectile.owner]; Vector2 launchVel = Utils.DirectionTo(Owner.Center, target.Center); - target.MoveNPC(launchVel, 10 * (launched ? 0.5f : 1), true); + target.MoveNPC(launchVel, 10 * (launched ? 0.5f : 1), true, Owner); } public override bool? CanHitNPC(NPC target) diff --git a/Projectiles/Magic/PrimordialAncientExplosion.cs b/Projectiles/Magic/PrimordialAncientExplosion.cs index f5783774a8..371b6cb0a1 100644 --- a/Projectiles/Magic/PrimordialAncientExplosion.cs +++ b/Projectiles/Magic/PrimordialAncientExplosion.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Magic public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center); - target.MoveNPC(launchVel, 40, true); + target.MoveNPC(launchVel, 40, true, Owner); if (Projectile.numHits > 0) Projectile.damage = (int)(Projectile.damage * 0.95f); diff --git a/Projectiles/Magic/PrimordialEarthExplosion.cs b/Projectiles/Magic/PrimordialEarthExplosion.cs index d35a7323a5..95ffc29e30 100644 --- a/Projectiles/Magic/PrimordialEarthExplosion.cs +++ b/Projectiles/Magic/PrimordialEarthExplosion.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Magic public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center); - target.MoveNPC(launchVel, 20, true); + target.MoveNPC(launchVel, 20, true, Owner); if (Projectile.numHits > 0) Projectile.damage = (int)(Projectile.damage * 0.9f); diff --git a/Projectiles/Magic/SHPB.cs b/Projectiles/Magic/SHPB.cs index 0183bcdc66..9f2231225d 100644 --- a/Projectiles/Magic/SHPB.cs +++ b/Projectiles/Magic/SHPB.cs @@ -266,11 +266,11 @@ namespace CalamityMod.Projectiles.Magic } // Might launches enemies - if (GetSoulEffects((int)Projectile.ai[0]) == SoulType.Might && target.CanBeMoved(false)) + if (GetSoulEffects((int)Projectile.ai[0]) == SoulType.Might && target.CanBeMoved()) { // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction Vector2 launchVel = Utils.DirectionTo(owner.Center, owner.Calamity().mouseWorld) - Vector2.UnitY * 5f; - target.MoveNPC(launchVel, SHPC.MightKnockbackStrength, false); + target.MoveNPC(launchVel, SHPC.MightKnockbackStrength, false, owner); } } diff --git a/Projectiles/Magic/SHPExplosion.cs b/Projectiles/Magic/SHPExplosion.cs index 4b0bda748a..04fec18c74 100644 --- a/Projectiles/Magic/SHPExplosion.cs +++ b/Projectiles/Magic/SHPExplosion.cs @@ -75,13 +75,13 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { // Might launches enemies - if (SHPB.GetSoulEffects((int)Projectile.ai[0]) == SHPB.SoulType.Might && target.CanBeMoved(false)) + if (SHPB.GetSoulEffects((int)Projectile.ai[0]) == SHPB.SoulType.Might && target.CanBeMoved()) { // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction Player owner = Main.player[Projectile.owner]; Vector2 launchVel = Utils.DirectionTo(owner.Center, owner.Calamity().mouseWorld) - Vector2.UnitY * 5f; - target.MoveNPC(launchVel, SHPC.MightKnockbackStrength, false); + target.MoveNPC(launchVel, SHPC.MightKnockbackStrength, false, owner); } } diff --git a/Projectiles/Melee/BasherHoldout.cs b/Projectiles/Melee/BasherHoldout.cs index 7f8ad74901..3428fbe1dc 100644 --- a/Projectiles/Melee/BasherHoldout.cs +++ b/Projectiles/Melee/BasherHoldout.cs @@ -239,7 +239,7 @@ namespace CalamityMod.Projectiles.Melee target.AddBuff(ModContent.BuffType(), 300); Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - target.MoveNPC(launchVel, 14f, true); + target.MoveNPC(launchVel, 14f, true, Owner); for (int i = 0; i < MathHelper.Clamp(15 - Projectile.numHits * 3, 2, 15); i++) { diff --git a/Projectiles/Melee/CometQuasherHoldout.cs b/Projectiles/Melee/CometQuasherHoldout.cs index fb612dd221..08ff873084 100644 --- a/Projectiles/Melee/CometQuasherHoldout.cs +++ b/Projectiles/Melee/CometQuasherHoldout.cs @@ -205,7 +205,7 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(fire2 with { Volume = 0.55f, Pitch = 0.7f }, Projectile.Center); Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - target.MoveNPC(launchVel, 7, true); + target.MoveNPC(launchVel, 7, true, Owner); for (int i = 0; i < MathHelper.Clamp(6 - Projectile.numHits * 2, 2, 6); i++) { diff --git a/Projectiles/Melee/DevilsDevastationHoldout.cs b/Projectiles/Melee/DevilsDevastationHoldout.cs index 501bccd737..093afc45b2 100644 --- a/Projectiles/Melee/DevilsDevastationHoldout.cs +++ b/Projectiles/Melee/DevilsDevastationHoldout.cs @@ -392,7 +392,7 @@ namespace CalamityMod.Projectiles.Melee } Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - CalamityUtils.MoveNPC(target, launchVel, 40, true); + CalamityUtils.MoveNPC(target, launchVel, 40, true, Owner); if (target.Calamity().demonSwordImpales != 0 || Projectile.numHits == 0) { diff --git a/Projectiles/Melee/DragoonBigBolt.cs b/Projectiles/Melee/DragoonBigBolt.cs index 828cbe7972..baf5c2aef5 100644 --- a/Projectiles/Melee/DragoonBigBolt.cs +++ b/Projectiles/Melee/DragoonBigBolt.cs @@ -127,7 +127,7 @@ namespace CalamityMod.Projectiles.Melee } Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center); - target.MoveNPC(launchVel, 20, true); + target.MoveNPC(launchVel, 20, true, Owner); } } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) diff --git a/Projectiles/Melee/EarthHoldout.cs b/Projectiles/Melee/EarthHoldout.cs index 2a230edb90..c51b91ec44 100644 --- a/Projectiles/Melee/EarthHoldout.cs +++ b/Projectiles/Melee/EarthHoldout.cs @@ -261,7 +261,7 @@ namespace CalamityMod.Projectiles.Melee armoredHits++; Vector2 launchVel = (Projectile.ai[1] != 1 ? Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) : Utils.DirectionTo(Owner.Center, target.Center)); - target.MoveNPC(launchVel, 37, true); + target.MoveNPC(launchVel, 37, true, Owner); if (spawnBoom) { diff --git a/Projectiles/Melee/ExaltedOathbladeHoldout.cs b/Projectiles/Melee/ExaltedOathbladeHoldout.cs index c4db13d8e4..279b825edd 100644 --- a/Projectiles/Melee/ExaltedOathbladeHoldout.cs +++ b/Projectiles/Melee/ExaltedOathbladeHoldout.cs @@ -251,7 +251,7 @@ namespace CalamityMod.Projectiles.Melee } Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - CalamityUtils.MoveNPC(target, launchVel, 23, true); + CalamityUtils.MoveNPC(target, launchVel, 23, true, Owner); int dustNum = (int)MathHelper.Clamp(12 - Projectile.numHits * 3, 3, 12); for (int i = 0; i < dustNum; i++) diff --git a/Projectiles/Melee/ForbiddenOathbladeHoldout.cs b/Projectiles/Melee/ForbiddenOathbladeHoldout.cs index b4088066bc..ba2800c800 100644 --- a/Projectiles/Melee/ForbiddenOathbladeHoldout.cs +++ b/Projectiles/Melee/ForbiddenOathbladeHoldout.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Cooldowns; @@ -307,7 +307,7 @@ namespace CalamityMod.Projectiles.Melee } Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - CalamityUtils.MoveNPC(target, launchVel, 17, true); + CalamityUtils.MoveNPC(target, launchVel, 17, true, Owner); int dustNum = (int)MathHelper.Clamp(12 - Projectile.numHits * 3, 3, 12); for (int i = 0; i < dustNum; i++) diff --git a/Projectiles/Melee/GrandDadHoldout.cs b/Projectiles/Melee/GrandDadHoldout.cs index ea8acf382e..630fa6b82b 100644 --- a/Projectiles/Melee/GrandDadHoldout.cs +++ b/Projectiles/Melee/GrandDadHoldout.cs @@ -293,7 +293,7 @@ namespace CalamityMod.Projectiles.Melee // Regular knockback float launchPower = 60; - target.MoveNPC(toMouse, launchPower * (canBeLaunched ? 0.5f : 0.25f), true); + target.MoveNPC(toMouse, launchPower * (canBeLaunched ? 0.5f : 0.25f), true, Owner); if (canBeLaunched) // launches/executes enemies { if (jared) diff --git a/Projectiles/Melee/GrandGuardianHoldout.cs b/Projectiles/Melee/GrandGuardianHoldout.cs index 51978ae71d..6ab245f9cd 100644 --- a/Projectiles/Melee/GrandGuardianHoldout.cs +++ b/Projectiles/Melee/GrandGuardianHoldout.cs @@ -194,7 +194,7 @@ namespace CalamityMod.Projectiles.Melee armoredHits++; Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - target.MoveNPC(launchVel, 8, true); + target.MoveNPC(launchVel, 8, true, Owner); if (spawnBoom) { diff --git a/Projectiles/Melee/HellkiteHoldout.cs b/Projectiles/Melee/HellkiteHoldout.cs index 07c121065c..f2595cf48f 100644 --- a/Projectiles/Melee/HellkiteHoldout.cs +++ b/Projectiles/Melee/HellkiteHoldout.cs @@ -390,7 +390,7 @@ namespace CalamityMod.Projectiles.Melee } Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - target.MoveNPC(launchVel, (chargedSwing ? 24 : 19), true); + target.MoveNPC(launchVel, (chargedSwing ? 24 : 19), true, Owner); } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { diff --git a/Projectiles/Melee/HolyColliderHoldout.cs b/Projectiles/Melee/HolyColliderHoldout.cs index 923f3e19c5..959a2e1553 100644 --- a/Projectiles/Melee/HolyColliderHoldout.cs +++ b/Projectiles/Melee/HolyColliderHoldout.cs @@ -438,7 +438,7 @@ namespace CalamityMod.Projectiles.Melee } Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - target.MoveNPC(launchVel, (chargedSwing ? 35 : 23), true); + target.MoveNPC(launchVel, (chargedSwing ? 35 : 23), true, Owner); } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { diff --git a/Projectiles/Melee/MajesticGuardHoldout.cs b/Projectiles/Melee/MajesticGuardHoldout.cs index ddb54e5253..b10a3a2a49 100644 --- a/Projectiles/Melee/MajesticGuardHoldout.cs +++ b/Projectiles/Melee/MajesticGuardHoldout.cs @@ -197,7 +197,7 @@ namespace CalamityMod.Projectiles.Melee } Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - target.MoveNPC(launchVel, 15, true); + target.MoveNPC(launchVel, 15, true, Owner); for (int i = 0; i < MathHelper.Clamp(6 - Projectile.numHits * 2, 2, 6); i++) { diff --git a/Projectiles/Melee/OldLordClaymoreHoldout.cs b/Projectiles/Melee/OldLordClaymoreHoldout.cs index 66ed0e1215..cf3264b909 100644 --- a/Projectiles/Melee/OldLordClaymoreHoldout.cs +++ b/Projectiles/Melee/OldLordClaymoreHoldout.cs @@ -190,7 +190,7 @@ namespace CalamityMod.Projectiles.Melee target.AddBuff(BuffID.OnFire3, 180); Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - CalamityUtils.MoveNPC(target, launchVel, 12, true); + CalamityUtils.MoveNPC(target, launchVel, 12, true, Owner); int dustNum = (int)MathHelper.Clamp(12 - Projectile.numHits * 3, 3, 12); for (int i = 0; i < dustNum; i++) diff --git a/Projectiles/Melee/Shortswords/GalileoGladiusThrown.cs b/Projectiles/Melee/Shortswords/GalileoGladiusThrown.cs index ae618ec5b3..0c3d240adb 100644 --- a/Projectiles/Melee/Shortswords/GalileoGladiusThrown.cs +++ b/Projectiles/Melee/Shortswords/GalileoGladiusThrown.cs @@ -219,7 +219,7 @@ namespace CalamityMod.Projectiles.Melee.Shortswords Particle boostRing = new CustomSpark(position, velocity, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, lifetime, scale, color, stretch, shrinkSpeed: shrink); GeneralParticleHandler.SpawnParticle(boostRing); - if (stabbedNPC.CanBeMoved(true)) + if (stabbedNPC.CanBeMoved()) { stabbedNPC.velocity = -Owner.velocity; } diff --git a/Projectiles/Melee/SkytideDragoonHoldout.cs b/Projectiles/Melee/SkytideDragoonHoldout.cs index 946245b17b..686133e319 100644 --- a/Projectiles/Melee/SkytideDragoonHoldout.cs +++ b/Projectiles/Melee/SkytideDragoonHoldout.cs @@ -298,7 +298,7 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(fire2 with { Volume = 0.65f, Pitch = 0.4f }, Projectile.Center); Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - target.MoveNPC(launchVel, 23, true); + target.MoveNPC(launchVel, 23, true, Owner); target.AddBuff(BuffID.Electrified, 230); } diff --git a/Projectiles/Melee/StellarStrikerHoldout.cs b/Projectiles/Melee/StellarStrikerHoldout.cs index 5dfff076cc..d06ba14221 100644 --- a/Projectiles/Melee/StellarStrikerHoldout.cs +++ b/Projectiles/Melee/StellarStrikerHoldout.cs @@ -202,7 +202,7 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(fire2 with { Volume = 0.55f, Pitch = 0.6f }, Projectile.Center); Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - target.MoveNPC(launchVel, 17, true); + target.MoveNPC(launchVel, 17, true, Owner); for (int i = 0; i < MathHelper.Clamp(10 - Projectile.numHits * 2, 2, 10); i++) { diff --git a/Projectiles/Ranged/FlashRoundFlash.cs b/Projectiles/Ranged/FlashRoundFlash.cs index 292698a737..6fb1571f0f 100644 --- a/Projectiles/Ranged/FlashRoundFlash.cs +++ b/Projectiles/Ranged/FlashRoundFlash.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Ranged { Player Owner = Main.player[Projectile.owner]; Vector2 launchVel = Utils.DirectionTo(Owner.Center, Projectile.Center); - target.MoveNPC(launchVel, 5, false); + target.MoveNPC(launchVel, 5, false, Owner); Vector2 dustVel = Utils.DirectionTo(Projectile.Center, target.Center); for (int i = 0; i < 3; i++) diff --git a/Projectiles/Ranged/HellbornProj.cs b/Projectiles/Ranged/HellbornProj.cs index 90705bfdf2..e53c485122 100644 --- a/Projectiles/Ranged/HellbornProj.cs +++ b/Projectiles/Ranged/HellbornProj.cs @@ -103,7 +103,7 @@ namespace CalamityMod.Projectiles.Ranged // Launch Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center); - target.MoveNPC(launchVel, 6, true); + target.MoveNPC(launchVel, 6, true, Owner); MakeBlast(target.whoAmI, true); } diff --git a/Projectiles/Ranged/NullFlash.cs b/Projectiles/Ranged/NullFlash.cs index 3654040cf2..3f728b5c57 100644 --- a/Projectiles/Ranged/NullFlash.cs +++ b/Projectiles/Ranged/NullFlash.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Ranged } Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - target.MoveNPC(launchVel, 20, true); + target.MoveNPC(launchVel, 20, true, Owner); } public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Ranged/OntoligicalDespoilerBurst.cs b/Projectiles/Ranged/OntoligicalDespoilerBurst.cs index 8877b11310..58d4c289ed 100644 --- a/Projectiles/Ranged/OntoligicalDespoilerBurst.cs +++ b/Projectiles/Ranged/OntoligicalDespoilerBurst.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Ranged Vector2 launchVel = Projectile.Center.DirectionTo(target.Center); float launchPower = 20; - target.MoveNPC(launchVel, launchPower, true); + target.MoveNPC(launchVel, launchPower, true, Owner); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 450, targetHitbox); } diff --git a/Projectiles/Ranged/OntologicalDespoilerBeam.cs b/Projectiles/Ranged/OntologicalDespoilerBeam.cs index 7281333710..9e8d5a9584 100644 --- a/Projectiles/Ranged/OntologicalDespoilerBeam.cs +++ b/Projectiles/Ranged/OntologicalDespoilerBeam.cs @@ -134,7 +134,7 @@ namespace CalamityMod.Projectiles.Ranged Vector2 launchVel = Projectile.velocity; float launchPower = 60; - target.MoveNPC(launchVel, launchPower, true); + target.MoveNPC(launchVel, launchPower, true, Owner); } public override bool? CanDamage() => Projectile.numHits < 1 ? null : false; public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Rogue/DoomsdayDeviceProjectile.cs b/Projectiles/Rogue/DoomsdayDeviceProjectile.cs index ebdf68342e..7f049480b7 100644 --- a/Projectiles/Rogue/DoomsdayDeviceProjectile.cs +++ b/Projectiles/Rogue/DoomsdayDeviceProjectile.cs @@ -343,7 +343,7 @@ namespace CalamityMod.Projectiles.Rogue Vector2 launchDir = Utils.DirectionTo(Projectile.Center, target.Center); float launchPower = ((hasReachedFullCharge ? 9 : 0) + charge * 1.5f) * finalHitMult; - target.MoveNPC(launchDir, launchPower, true); + target.MoveNPC(launchDir, launchPower, true, Owner); float extraPitch = (Owner.Calamity().rogueStealthMax > 0 ? (0.25f * (Owner.Calamity().rogueStealth / Owner.Calamity().rogueStealthMax)) : 0); diff --git a/Projectiles/Rogue/ExorcismShockwave.cs b/Projectiles/Rogue/ExorcismShockwave.cs index 25e1abd09a..6257692b1c 100644 --- a/Projectiles/Rogue/ExorcismShockwave.cs +++ b/Projectiles/Rogue/ExorcismShockwave.cs @@ -25,6 +25,7 @@ namespace CalamityMod.Projectiles.Rogue } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { + Player Owner = Main.player[Projectile.owner]; float minMult = 0.35f; int hitsToMinMult = 15; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); @@ -32,7 +33,7 @@ namespace CalamityMod.Projectiles.Rogue Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center) - Vector2.UnitY; float launchPower = (Projectile.Calamity().stealthStrike ? 4f : 1) * 10; - target.MoveNPC(launchVel, launchPower, true); + target.MoveNPC(launchVel, launchPower, true, Owner); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { diff --git a/Projectiles/Rogue/LeviathanToothStealth.cs b/Projectiles/Rogue/LeviathanToothStealth.cs index 24fdafda21..90da6945bf 100644 --- a/Projectiles/Rogue/LeviathanToothStealth.cs +++ b/Projectiles/Rogue/LeviathanToothStealth.cs @@ -120,7 +120,7 @@ namespace CalamityMod.Projectiles.Rogue if (hitTimer == 0) hitTimer = Projectile.localNPCHitCooldown; - if (target.CanBeMoved(true)) + if (target.CanBeMoved()) target.velocity *= 0.05f; } public override bool? CanDamage() => canDamage ? null : false; diff --git a/Projectiles/Rogue/PumpkaboomBig.cs b/Projectiles/Rogue/PumpkaboomBig.cs index 7439fa10fd..310ecffa27 100644 --- a/Projectiles/Rogue/PumpkaboomBig.cs +++ b/Projectiles/Rogue/PumpkaboomBig.cs @@ -107,7 +107,7 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i < Main.maxNPCs; i++) { NPC target = Main.npc[i]; - if (target != null && target.active && target.CanBeMoved(true) && Collision.CanHit(Projectile.Center, 1, 1, target.Center, 1, 1) && Vector2.Distance(target.Center, Projectile.Center) < maxPullDistance) + if (target != null && target.active && target.CanBeMoved() && Collision.CanHit(Projectile.Center, 1, 1, target.Center, 1, 1) && Vector2.Distance(target.Center, Projectile.Center) < maxPullDistance) { if (target.whoAmI == stuckNPC) continue; diff --git a/Projectiles/Rogue/SupernovaBoom.cs b/Projectiles/Rogue/SupernovaBoom.cs index 9d920c69f4..72676d8d23 100644 --- a/Projectiles/Rogue/SupernovaBoom.cs +++ b/Projectiles/Rogue/SupernovaBoom.cs @@ -162,7 +162,7 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i < Main.maxNPCs; i++) { NPC target = Main.npc[i]; - if (target.CanBeMoved(true) && target.CanBeChasedBy(Projectile, false)) + if (target.CanBeMoved() && target.CanBeChasedBy(Projectile, false)) { if (Vector2.Distance(target.Center, Projectile.Center) > 40 && Vector2.Distance(target.Center, Projectile.Center) < 600) { @@ -212,7 +212,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center); - target.MoveNPC(launchVel, 30, true); + target.MoveNPC(launchVel, 30, true, Owner); target.AddBuff(ModContent.BuffType(), 90); } diff --git a/Projectiles/Rogue/SupernovaStealthBoom.cs b/Projectiles/Rogue/SupernovaStealthBoom.cs index 21f394d99a..291086f2d7 100644 --- a/Projectiles/Rogue/SupernovaStealthBoom.cs +++ b/Projectiles/Rogue/SupernovaStealthBoom.cs @@ -221,7 +221,7 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i < Main.maxNPCs; i++) { NPC target = Main.npc[i]; - if (target.CanBeMoved(true) && target.CanBeChasedBy(Projectile, false)) + if (target.CanBeMoved() && target.CanBeChasedBy(Projectile, false)) { if (target != null && !CalamityPlayer.areThereAnyDamnBosses) { @@ -284,7 +284,7 @@ namespace CalamityMod.Projectiles.Rogue } Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center); - target.MoveNPC(launchVel, 60, true); + target.MoveNPC(launchVel, 60, true, Owner); } } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) // Add to regular plz diff --git a/Projectiles/Rogue/WhitewaterAura.cs b/Projectiles/Rogue/WhitewaterAura.cs index 466840dfc2..a1a3c6b70c 100644 --- a/Projectiles/Rogue/WhitewaterAura.cs +++ b/Projectiles/Rogue/WhitewaterAura.cs @@ -65,11 +65,12 @@ namespace CalamityMod.Projectiles.Rogue } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + Player Owner = Main.player[Projectile.owner]; target.AddBuff(BuffID.Wet, 300); target.AddBuff(ModContent.BuffType(), 300); Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center); - target.MoveNPC(launchVel, 9, true); + target.MoveNPC(launchVel, 9, true, Owner); } public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Summon/BrittleStarMinion.cs b/Projectiles/Summon/BrittleStarMinion.cs index 59a7afc0be..5344a200dc 100644 --- a/Projectiles/Summon/BrittleStarMinion.cs +++ b/Projectiles/Summon/BrittleStarMinion.cs @@ -215,7 +215,7 @@ namespace CalamityMod.Projectiles.Summon modifiers.SourceDamage *= damageMult; Vector2 launchVel = Utils.DirectionTo(Owner.Center, target.Center); - target.MoveNPC(launchVel, (MinionBuffMode ? 5f : 0.5f), false); + target.MoveNPC(launchVel, (MinionBuffMode ? 5f : 0.5f), false, Owner); } public override bool MinionContactDamage() => !Reforming; } diff --git a/Projectiles/Typeless/BasicBurst.cs b/Projectiles/Typeless/BasicBurst.cs index df59243a41..10feff399b 100644 --- a/Projectiles/Typeless/BasicBurst.cs +++ b/Projectiles/Typeless/BasicBurst.cs @@ -64,16 +64,14 @@ namespace CalamityMod.Projectiles.Typeless { target.AddBuff((int)(Projectile.localAI[2]), (int)(Projectile.localAI[1])); } - pushVelocity = Utils.DirectionTo(Projectile.Center, target.Center) * customKnockback; + pushVelocity = Utils.DirectionTo(Projectile.Center, target.Center); float minMult = Projectile.ai[1]; int hitsToMinMult = (int)Projectile.ai[2]; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); modifiers.SourceDamage *= damageMult; - if (customKnockback != 0 && target.CanBeMoved(hasStongDisplacement)) - { - target.velocity = (pushVelocity * (target.knockBackResist == 0 ? 0.5f : 1)); - } + if (customKnockback != 0) + target.MoveNPC(pushVelocity, customKnockback, hasStongDisplacement, Main.player[Projectile.owner]); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { diff --git a/Projectiles/Typeless/BasicBurstExclusive.cs b/Projectiles/Typeless/BasicBurstExclusive.cs index b5297f95f8..3a75ed111f 100644 --- a/Projectiles/Typeless/BasicBurstExclusive.cs +++ b/Projectiles/Typeless/BasicBurstExclusive.cs @@ -62,16 +62,14 @@ namespace CalamityMod.Projectiles.Typeless { target.AddBuff((int)(Projectile.localAI[1]), (int)(Projectile.localAI[2])); } - pushVelocity = Utils.DirectionTo(Projectile.Center, target.Center) * customKnockback; + pushVelocity = Utils.DirectionTo(Projectile.Center, target.Center); float minMult = Projectile.ai[1]; int hitsToMinMult = (int)Projectile.ai[2]; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); modifiers.SourceDamage *= damageMult; - if (customKnockback != 0 && target.CanBeMoved(hasStongDisplacement)) - { - target.velocity = (pushVelocity * (target.knockBackResist == 0 ? 0.5f : 1)); - } + if (customKnockback != 0) + target.MoveNPC(pushVelocity, customKnockback, hasStongDisplacement, Main.player[Projectile.owner]); } public override bool? CanHitNPC(NPC target) { diff --git a/Projectiles/Typeless/BatholithBangleProjectile.cs b/Projectiles/Typeless/BatholithBangleProjectile.cs index efd000c2c1..85919f69ec 100644 --- a/Projectiles/Typeless/BatholithBangleProjectile.cs +++ b/Projectiles/Typeless/BatholithBangleProjectile.cs @@ -123,7 +123,7 @@ namespace CalamityMod.Projectiles.Typeless Vector2 launchVel = Utils.DirectionTo(Owner.Center, target.Center) - Vector2.UnitY; float launchPower = 9; - target.MoveNPC(launchVel, launchPower, true); + target.MoveNPC(launchVel, launchPower, true, Owner); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * 0.5f, targetHitbox); public override bool? CanDamage() diff --git a/Projectiles/Typeless/DiamondOfTheDeepProjectile.cs b/Projectiles/Typeless/DiamondOfTheDeepProjectile.cs index c8339673f9..8fa99e61c3 100644 --- a/Projectiles/Typeless/DiamondOfTheDeepProjectile.cs +++ b/Projectiles/Typeless/DiamondOfTheDeepProjectile.cs @@ -446,7 +446,7 @@ namespace CalamityMod.Projectiles.Typeless // HADAL and VOID have knockback, GRAVEL has it's knockback on the explosion Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center) - Vector2.UnitY; float launchPower = 7f; - target.MoveNPC(launchVel, launchPower, false); + target.MoveNPC(launchVel, launchPower, false, Owner); if (visuals) { diff --git a/Projectiles/Typeless/DirectStrike.cs b/Projectiles/Typeless/DirectStrike.cs index b29d83d206..9436c4835d 100644 --- a/Projectiles/Typeless/DirectStrike.cs +++ b/Projectiles/Typeless/DirectStrike.cs @@ -57,9 +57,9 @@ namespace CalamityMod.Projectiles.Typeless if (projHitbox.Intersects(targetHitbox)) { NPC target = Main.npc[(int)Projectile.ai[0]]; - if (pushVelocity != Vector2.Zero && pushVelocity.X < 255f && !invalidTarget && target.CanBeMoved(hasStongDisplacement)) + if (pushVelocity != Vector2.Zero && pushVelocity.X < 255f && !invalidTarget) { - target.velocity = (pushVelocity * (target.knockBackResist == 0 ? 0.5f : 1)); + target.MoveNPC(pushVelocity, pushVelocity.Length(), hasStongDisplacement, Main.player[Projectile.owner]); } return true; } diff --git a/Projectiles/Typeless/LeviAmberDash.cs b/Projectiles/Typeless/LeviAmberDash.cs index a77ac9724f..40337949c0 100644 --- a/Projectiles/Typeless/LeviAmberDash.cs +++ b/Projectiles/Typeless/LeviAmberDash.cs @@ -126,7 +126,7 @@ namespace CalamityMod.Projectiles.Typeless target.AddBuff(ModContent.BuffType(), 180); Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - target.MoveNPC(launchVel, 20, true); + target.MoveNPC(launchVel, 20, true, Owner); for (int i = 0; i <= 17; i++) { diff --git a/Projectiles/Typeless/PauldronExplosion.cs b/Projectiles/Typeless/PauldronExplosion.cs index eddb8cb142..0dd79cde37 100644 --- a/Projectiles/Typeless/PauldronExplosion.cs +++ b/Projectiles/Typeless/PauldronExplosion.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Typeless modifiers.SourceDamage *= damageMult; Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - target.MoveNPC(launchVel, 15, true); + target.MoveNPC(launchVel, 15, true, Owner); } public override bool? CanCutTiles() => false; diff --git a/Projectiles/Typeless/ProtolithBangleProjectile.cs b/Projectiles/Typeless/ProtolithBangleProjectile.cs index f50a544547..fae2961e9b 100644 --- a/Projectiles/Typeless/ProtolithBangleProjectile.cs +++ b/Projectiles/Typeless/ProtolithBangleProjectile.cs @@ -111,7 +111,7 @@ namespace CalamityMod.Projectiles.Typeless Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center) - Vector2.UnitY; float launchPower = 6; - target.MoveNPC(launchVel, launchPower, true); + target.MoveNPC(launchVel, launchPower, true, Owner); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * 0.5f * Projectile.scale, targetHitbox); public override bool? CanDamage() diff --git a/Projectiles/Typeless/PuddleSplash.cs b/Projectiles/Typeless/PuddleSplash.cs index 0d8dff4a2c..56e251accc 100644 --- a/Projectiles/Typeless/PuddleSplash.cs +++ b/Projectiles/Typeless/PuddleSplash.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Typeless { target.AddBuff(BuffID.Wet, 180); Vector2 launchVel = Utils.DirectionTo(Owner.Center, target.Center) + Vector2.UnitY * -0.75f; - target.MoveNPC(launchVel, 12, false); + target.MoveNPC(launchVel, 12, false, Owner); } public override bool? CanCutTiles() => false; } diff --git a/Projectiles/Typeless/TransformerBlob.cs b/Projectiles/Typeless/TransformerBlob.cs index a3fc1c1c55..c9fa8c8bdc 100644 --- a/Projectiles/Typeless/TransformerBlob.cs +++ b/Projectiles/Typeless/TransformerBlob.cs @@ -237,7 +237,7 @@ namespace CalamityMod.Projectiles.Typeless else modifiers.SourceDamage *= 0.2f; - target.MoveNPC(Utils.DirectionTo(Owner.Center, target.Center), (poweredTimer == 0 ? 7 : 3)); + target.MoveNPC(Utils.DirectionTo(Owner.Center, target.Center), (poweredTimer == 0 ? 7 : 3), false, Owner); if (Projectile.numHits == 0 && poweredTimer == 0) { diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index c360a2d7ea..0141f7a60f 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -1,12 +1,18 @@ using System; +using System; +using System.Collections.Generic; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Reflection; +using CalamityMod.Balancing; using CalamityMod.Balancing; using CalamityMod.CalPlayer; using CalamityMod.DataStructures; using CalamityMod.Enums; using CalamityMod.Events; +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Armor; using CalamityMod.NPCs; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.OldDuke; @@ -16,17 +22,22 @@ using CalamityMod.NPCs.SunkenSea; using CalamityMod.NPCs.Yharon; using CalamityMod.Packets; using CalamityMod.Systems.Collections; +using CalamityMod.Systems.Collections; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria; using Terraria.Audio; using Terraria.Chat; using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; using static Terraria.ModLoader.ModContent; namespace CalamityMod @@ -732,14 +743,11 @@ namespace CalamityMod /// /// The NPC attacked. /// Whether or not the NPC can be moved around. - public static bool CanBeMoved(this NPC target, bool ignoreKBImmune = false) + public static bool CanBeMoved(this NPC target) { - // Ideally we can replace [!CalamityPlayer.areThereAnyDamnBosses] with a check for problematic boss minions so that you can knock back regular ones in bossfights. - // For now at least, when a boss is alive it will always fail to knockback enemies with 100% kb resist. - if (CalamityPlayer.areThereAnyDamnBosses) - ignoreKBImmune = false; - bool isAPillar = target.type == NPCID.LunarTowerSolar || target.type == NPCID.LunarTowerVortex || target.type == NPCID.LunarTowerNebula || target.type == NPCID.LunarTowerStardust; - if (!isAPillar && !target.boss && target.IsAnEnemy(true, true, false) && (ignoreKBImmune || target.knockBackResist > 0)) + bool whitelisted = CalamityHeavyKnockbackWhitelist.whitelistNPC.Contains(target.type); + + if ((target.knockBackResist != 0 || whitelisted) && target.IsAnEnemy(true, true, false)) return true; return false; } @@ -748,13 +756,15 @@ namespace CalamityMod /// /// The NPC being moved. /// Whether or not NPC's that normally have knockback immunity can be moved around. - public static void MoveNPC(this NPC target, Vector2 direction, float strength, bool ignoreKBImmune = false) + public static void MoveNPC(this NPC target, Vector2 direction, float strength, bool heavyKnockback = false, Player attacker = null) { - if (target.CanBeMoved(ignoreKBImmune)) + if (target.CanBeMoved()) { Vector2 launchVel = direction.SafeNormalize(Vector2.UnitX) * strength; - float knockbackMult = Utils.Remap(target.knockBackResist, 0, 1, 0.5f, 1f, false); - target.velocity = launchVel * (knockbackMult > 1 ? (float)Math.Pow(knockbackMult, 10) : knockbackMult); + float playerKnockbackMult = attacker != null ? (attacker.GetTotalKnockback().ApplyTo(1)) : 1; + Main.NewText(attacker.GetKnockback().ApplyTo(1)); + float knockbackMult = playerKnockbackMult * (heavyKnockback ? Math.Max(target.knockBackResist, 1) : target.knockBackResist); // Heavy knockback ignores knockback resist (but not knockback weakness) + target.velocity = launchVel * knockbackMult; target.SyncMotionToServer(); } }