From 0562c104ee14c9d04b7e6caeef6b157ee9515fc5 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Sat, 8 Mar 2025 23:59:10 -0500 Subject: [PATCH 1/9] Added CountOwnedProjectiles method. Same as CountProjectiles except it has an owner check Replaced CountProjectiles with CountOwnedProjectiles in all appropriate cases Also added a new GlobalNPC variable for Giant Pearl to help facilitate this change with it --- CalPlayer/CalamityPlayerMiscEffects.cs | 7 +++++-- Items/Weapons/Melee/Avalanche.cs | 2 +- Items/Weapons/Melee/GaelsGreatsword.cs | 2 +- Items/Weapons/Summon/DazzlingStabberStaff.cs | 6 +++--- NPCs/CalamityGlobalNPC.cs | 13 +++++++++++-- Projectiles/Magic/EternityHex.cs | 2 +- Projectiles/Rogue/RefractionRotorProjectile.cs | 2 +- Projectiles/Summon/AndromedaRegislash.cs | 2 +- Projectiles/Summon/EndoHydraHead.cs | 2 +- Projectiles/Summon/GammaHead.cs | 4 ++-- Utilities/ProjectileUtils.cs | 1 + 11 files changed, 28 insertions(+), 15 deletions(-) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 4e2e38444b..75015c9458 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -1609,7 +1609,7 @@ namespace CalamityMod.CalPlayer { float insanityValue = ((p.ai[1] % 10) + 1); if (p.ai[0] == layer) - p.ai[2] = insanityValue / CalamityUtils.CountProjectiles(ModContent.ProjectileType()) * (angleMax) - (angleMax) / 2f; + p.ai[2] = insanityValue / CalamityUtils.CountOwnedProjectiles(ModContent.ProjectileType(), Player.whoAmI) * (angleMax) - (angleMax) / 2f; p.netUpdate = true; } @@ -1660,7 +1660,7 @@ namespace CalamityMod.CalPlayer { float insanityValue = ((p.ai[1] % 10) + 1); if (p.ai[0] == layer) - p.ai[2] = insanityValue / CalamityUtils.CountProjectiles(ModContent.ProjectileType()) * (angleMax) - (angleMax) / 2f; + p.ai[2] = insanityValue / CalamityUtils.CountOwnedProjectiles(ModContent.ProjectileType(), Player.whoAmI) * (angleMax) - (angleMax) / 2f; p.netUpdate = true; index++; @@ -3395,7 +3395,10 @@ namespace CalamityMod.CalPlayer continue; float distance = (npc.Center - Player.Center).Length(); if (distance < GiantPearl.AuraRadius) + { npc.AddBuff(ModContent.BuffType(), 20, false); + npc.Calamity().pearlAuraOwner = Player.whoAmI; + } } } } diff --git a/Items/Weapons/Melee/Avalanche.cs b/Items/Weapons/Melee/Avalanche.cs index 43273d55d4..af32ff182b 100644 --- a/Items/Weapons/Melee/Avalanche.cs +++ b/Items/Weapons/Melee/Avalanche.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { int type = ModContent.ProjectileType(); - if (CalamityUtils.CountProjectiles(type) < 16) + if (CalamityUtils.CountOwnedProjectiles(type, player.whoAmI) < 16) { var source = player.GetSource_ItemUse(Item); int bombDamage = player.CalcIntDamage(Item.damage); diff --git a/Items/Weapons/Melee/GaelsGreatsword.cs b/Items/Weapons/Melee/GaelsGreatsword.cs index 54745229f2..4d78166bc2 100644 --- a/Items/Weapons/Melee/GaelsGreatsword.cs +++ b/Items/Weapons/Melee/GaelsGreatsword.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void MeleeEffects(Player player, Rectangle hitbox) { var source = player.GetSource_ItemUse(Item); - if (CalamityUtils.CountProjectiles(ModContent.ProjectileType()) < 3 && + if (CalamityUtils.CountOwnedProjectiles(ModContent.ProjectileType(), player.whoAmI) < 3 && player.statLife <= player.statLifeMax2 * 0.5f && Main.myPlayer == player.whoAmI) { diff --git a/Items/Weapons/Summon/DazzlingStabberStaff.cs b/Items/Weapons/Summon/DazzlingStabberStaff.cs index 1efc69bdab..477f451751 100644 --- a/Items/Weapons/Summon/DazzlingStabberStaff.cs +++ b/Items/Weapons/Summon/DazzlingStabberStaff.cs @@ -48,19 +48,19 @@ namespace CalamityMod.Items.Weapons.Summon } } float angleMax = MathHelper.ToRadians(360f); - if (CalamityUtils.CountProjectiles(type) == 1) + if (CalamityUtils.CountOwnedProjectiles(type, player.whoAmI) == 1) angleMax = 0f; float index = 1f; if (player.ownedProjectileCounts[Item.shoot] > 30) { angleMax += MathHelper.ToRadians((player.ownedProjectileCounts[Item.shoot] - 30) * 2.5f); } - angleMax = angleMax > MathHelper.ToRadians(360f) ? MathHelper.ToRadians(360f) : angleMax; // More intuative than using a min function + angleMax = angleMax > MathHelper.ToRadians(360f) ? MathHelper.ToRadians(360f) : angleMax; // More intuitive than using a min function foreach (Projectile p in Main.ActiveProjectiles) { if (p.type == type && p.owner == player.whoAmI) { - p.ai[1] = (index / CalamityUtils.CountProjectiles(type)) * angleMax - angleMax / 2f; + p.ai[1] = (index / CalamityUtils.CountOwnedProjectiles(type, player.whoAmI)) * angleMax - angleMax / 2f; p.netUpdate = true; index++; } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 08627aaf7d..d21dfd4e62 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -302,6 +302,11 @@ namespace CalamityMod.NPCs /// Used to determine when Giant Pearl's pearl shards should rain down onto the NPC. /// public int pearlAuraCounter = 0; + /// + /// When an NPC is inflicted with Pearl Aura, this variable is set to index of the player who inflicted it.
+ /// Used for properly counting pearl shard amount and for giving pearl shards an owner. + ///
+ public int pearlAuraOwner = -1; public int bBlood = 0; public int brainRot = 0; public int heavybleeding = 0; @@ -5815,20 +5820,24 @@ namespace CalamityMod.NPCs SoundEngine.PlaySound(SoundID.Item49, npc.Center); // Prevent things from getting too crazy - if (CalamityUtils.CountProjectiles(ProjectileType()) <= 3) + // CIT 8MAR2025: It is assumed that pearlAuraOwner is always set to something other than -1 when this code is run. + if (CalamityUtils.CountOwnedProjectiles(ProjectileType(), pearlAuraOwner) <= 3) { for (int i = 0; i < 3; i++) { Vector2 shardPos = npc.Center + new Vector2(Main.rand.NextFloat(-100f, 100f), Main.rand.NextFloat(-500f, -650f)); Vector2 shardVel = Vector2.Normalize(npc.Center - shardPos).RotatedByRandom(MathHelper.Pi / 55f) * 20f; int damage = 20; - Projectile.NewProjectile(npc.GetSource_FromThis(), shardPos, shardVel, ProjectileType(), damage, 5f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromThis(), shardPos, shardVel, ProjectileType(), damage, 5f, pearlAuraOwner); } } } } else + { pearlAuraCounter = 0; + pearlAuraOwner = -1; + } if (demonSwordImpales > 0 && npc.CanBeMoved(true)) { diff --git a/Projectiles/Magic/EternityHex.cs b/Projectiles/Magic/EternityHex.cs index c52e625edf..ce073f8144 100644 --- a/Projectiles/Magic/EternityHex.cs +++ b/Projectiles/Magic/EternityHex.cs @@ -139,7 +139,7 @@ namespace CalamityMod.Projectiles.Magic // Release bursts of homing dark magic bolts periodically. The amount of bolts that can be summoned has a hard limit. // This is where most of the damage comes from. Be careful when messing with this. - if ((int)Time % 30 == 0 && CalamityUtils.CountProjectiles(ModContent.ProjectileType()) < Eternity.MaxHomers) + if ((int)Time % 30 == 0 && CalamityUtils.CountOwnedProjectiles(ModContent.ProjectileType(), Projectile.owner) < Eternity.MaxHomers) { int homerCount = 6; int damage = (int)player.GetTotalDamage().ApplyTo(0.8f * Eternity.BaseDamage); diff --git a/Projectiles/Rogue/RefractionRotorProjectile.cs b/Projectiles/Rogue/RefractionRotorProjectile.cs index 7766f7032b..202178f0a5 100644 --- a/Projectiles/Rogue/RefractionRotorProjectile.cs +++ b/Projectiles/Rogue/RefractionRotorProjectile.cs @@ -109,7 +109,7 @@ namespace CalamityMod.Projectiles.Rogue if (Main.myPlayer != Projectile.owner) return; - if (CalamityUtils.CountProjectiles(shootType) > 24) + if (CalamityUtils.CountOwnedProjectiles(shootType, Projectile.owner) > 24) return; int energyDamage = (int)(Projectile.damage * 0.5f); diff --git a/Projectiles/Summon/AndromedaRegislash.cs b/Projectiles/Summon/AndromedaRegislash.cs index b536ddb8ea..17bdca96bc 100644 --- a/Projectiles/Summon/AndromedaRegislash.cs +++ b/Projectiles/Summon/AndromedaRegislash.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Summon Player player = Main.player[Projectile.owner]; if (Projectile.localAI[0] == 0f) { - if (CalamityUtils.CountProjectiles(Projectile.type) > 1) + if (CalamityUtils.CountOwnedProjectiles(Projectile.type, Projectile.owner) > 1) { Projectile.Kill(); return; diff --git a/Projectiles/Summon/EndoHydraHead.cs b/Projectiles/Summon/EndoHydraHead.cs index 70066ab2dc..cb231e8ac5 100644 --- a/Projectiles/Summon/EndoHydraHead.cs +++ b/Projectiles/Summon/EndoHydraHead.cs @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Summon return; } - int totalHeads = CalamityUtils.CountProjectiles(Projectile.type); + int totalHeads = CalamityUtils.CountOwnedProjectiles(Projectile.type, Projectile.owner); if (Projectile.localAI[0] == 0f) { DeltaPosition = DeltaPositionMoving = new Vector2(Main.rand.NextFloat(-72f - 8f * totalHeads, 72f + 8f * totalHeads), -Main.rand.NextFloat(8f, 84f + 4f * totalHeads)); diff --git a/Projectiles/Summon/GammaHead.cs b/Projectiles/Summon/GammaHead.cs index 8ef0bd290e..c769643882 100644 --- a/Projectiles/Summon/GammaHead.cs +++ b/Projectiles/Summon/GammaHead.cs @@ -97,7 +97,7 @@ namespace CalamityMod.Projectiles.Summon public void PerformInitializationEffects() { - int totalHeads = CalamityUtils.CountProjectiles(Projectile.type); + int totalHeads = CalamityUtils.CountOwnedProjectiles(Projectile.type, Projectile.owner); CurrentPositionOffset = IdealPositionOffset = new Vector2(Main.rand.NextFloat(-72f - 8f * totalHeads, 72f + 8f * totalHeads), -Main.rand.NextFloat(8f, 84f + 4f * totalHeads)); Projectile.netUpdate = true; @@ -169,7 +169,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.velocity = (Projectile.velocity * 9f + Projectile.SafeDirectionTo(returnPosition) * flySpeed) / 10f; } - int totalHeads = CalamityUtils.CountProjectiles(Projectile.type); + int totalHeads = CalamityUtils.CountOwnedProjectiles(Projectile.type, Projectile.owner); int moveRate = 40 + totalHeads * 4; // Reset the ideal offset from time to time. diff --git a/Utilities/ProjectileUtils.cs b/Utilities/ProjectileUtils.cs index 286d601738..5d09f8fb37 100644 --- a/Utilities/ProjectileUtils.cs +++ b/Utilities/ProjectileUtils.cs @@ -40,6 +40,7 @@ namespace CalamityMod } public static int CountProjectiles(int projectileID) => Main.projectile.Count(proj => proj.type == projectileID && proj.active); + public static int CountOwnedProjectiles(int projectileID, int ownerID) => Main.projectile.Count(proj => proj.active && proj.type == projectileID && proj.owner == ownerID); public static int CountHookProj() => Main.projectile.Count(proj => Main.projHook[proj.type] && proj.ai[0] == 2f && proj.active && proj.owner == Main.myPlayer); From 11f61fbc5649d1c0f83dafe8e6557a97070e4e0a Mon Sep 17 00:00:00 2001 From: shade-storm Date: Sun, 9 Mar 2025 00:21:07 -0600 Subject: [PATCH 2/9] Titan heart armor no longer makes you attack slower (buffs spam, nerfs stealth which saves us time balancing that tier since that was its issue). Titan heart armor now actually gives knockback Moved 5% of dmg from setbonus to chestplate --- Items/Armor/TitanHeart/TitanHeartBoots.cs | 1 + Items/Armor/TitanHeart/TitanHeartMantle.cs | 4 ++-- Items/Armor/TitanHeart/TitanHeartMask.cs | 3 ++- .../en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Items/Armor/TitanHeart/TitanHeartBoots.cs b/Items/Armor/TitanHeart/TitanHeartBoots.cs index ae7ef7e9f4..8f557bba6f 100644 --- a/Items/Armor/TitanHeart/TitanHeartBoots.cs +++ b/Items/Armor/TitanHeart/TitanHeartBoots.cs @@ -24,6 +24,7 @@ namespace CalamityMod.Items.Armor.TitanHeart player.Calamity().titanHeartBoots = true; player.Calamity().rogueVelocity += 0.1f; player.GetDamage() += 0.04f; + player.GetKnockback() += 0.05f; } public override void AddRecipes() diff --git a/Items/Armor/TitanHeart/TitanHeartMantle.cs b/Items/Armor/TitanHeart/TitanHeartMantle.cs index 8a7129a95b..6a972d1c89 100644 --- a/Items/Armor/TitanHeart/TitanHeartMantle.cs +++ b/Items/Armor/TitanHeart/TitanHeartMantle.cs @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Armor.TitanHeart public override void UpdateEquip(Player player) { player.Calamity().titanHeartMantle = true; - // 15% attack speed penalty - player.GetAttackSpeed() -= 0.15f; + player.GetKnockback() += 0.05f; + player.GetDamage() += 0.05f; } public override void AddRecipes() diff --git a/Items/Armor/TitanHeart/TitanHeartMask.cs b/Items/Armor/TitanHeart/TitanHeartMask.cs index 479a5b5b25..72638f6fff 100644 --- a/Items/Armor/TitanHeart/TitanHeartMask.cs +++ b/Items/Armor/TitanHeart/TitanHeartMask.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Armor.TitanHeart player.setBonus = this.GetLocalizedValue("SetBonus"); var modPlayer = player.Calamity(); modPlayer.titanHeartSet = true; - player.GetDamage() += 0.15f; + player.GetDamage() += 0.10f; modPlayer.rogueStealthMax += 1f; modPlayer.wearingRogueArmor = true; player.noKnockback = true; @@ -41,6 +41,7 @@ namespace CalamityMod.Items.Armor.TitanHeart var modPlayer = player.Calamity(); modPlayer.titanHeartMask = true; player.GetDamage() += 0.05f; + player.GetKnockback() += 0.05f; } public override void AddRecipes() diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson index 8b8e2f204b..2976896ad0 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson @@ -522,7 +522,7 @@ TitanHeartBoots: { TitanHeartMantle: { DisplayName: Titan Heart Mantle - Tooltip: 5% boosted rogue knockback but 15% lowered rogue attack speed + Tooltip: 5% boosted rogue damage and knockback } TitanHeartMask: { @@ -534,7 +534,7 @@ TitanHeartMask: { ''' SetBonus: ''' - 15% increased rogue damage and knockback + 10% increased rogue damage and knockback +100 maximum stealth Stealth strikes deal double knockback and cause an astral explosion Grants immunity to knockback From f094ad619700f70e14a50b4e4dad15e5d20e1d24 Mon Sep 17 00:00:00 2001 From: shade-storm Date: Sun, 9 Mar 2025 00:23:17 -0600 Subject: [PATCH 3/9] Actually why not give Raider's the buff in the main branch since rn its not worth using at all --- Items/Accessories/RaidersTalisman.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Accessories/RaidersTalisman.cs b/Items/Accessories/RaidersTalisman.cs index ced3c36784..7ded8661aa 100644 --- a/Items/Accessories/RaidersTalisman.cs +++ b/Items/Accessories/RaidersTalisman.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Accessories { public new string LocalizationCategory => "Items.Accessories"; public const float RaiderBonus = 10f; - public const int RaiderCooldown = 5; + public const int RaiderCooldown = 10; public static readonly SoundStyle StealthHitSound = new("CalamityMod/Sounds/Custom/RaidersTalismanStealthHit"); public override void SetDefaults() From 5007fb87d132ffdf3d55bb17d0623d1cbbbba9c7 Mon Sep 17 00:00:00 2001 From: shade-storm Date: Sun, 9 Mar 2025 00:33:30 -0600 Subject: [PATCH 4/9] Nerfed rain since dealing 1/3 of what a weapon does post-1 mech is not ok. Also can someone find where it gives 10% summon and crit and nerf that to something like 5%? It would be appreciated since this thing is too damn strong --- CalPlayer/CalamityPlayerHitHurt.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index 4dcd101eb0..32dc6b33e5 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -2647,7 +2647,7 @@ namespace CalamityMod.CalPlayer { var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); int effectStrength = amalgam ? 3 : aBrain ? 2 : 1; - int effectDamage = amalgam ? 400 : aBrain ? 50 : 15; + int effectDamage = amalgam ? 400 : aBrain ? 35 : 15; effectDamage = (int)Player.GetBestClassDamage().ApplyTo(effectDamage); Vector2 spawnerVelocity = -Vector2.UnitY.RotatedByRandom(MathHelper.Pi / 40f) * 12.5f; From 4c2c2110760d5170d8313aa44fad7e2a50050e16 Mon Sep 17 00:00:00 2001 From: shade-storm Date: Sun, 9 Mar 2025 00:35:02 -0600 Subject: [PATCH 5/9] Apparently Titan Heart gives knockback in ModifyWeaponKnockback for some reason --- Items/Armor/TitanHeart/TitanHeartBoots.cs | 1 - Items/Armor/TitanHeart/TitanHeartMantle.cs | 1 - Items/Armor/TitanHeart/TitanHeartMask.cs | 1 - 3 files changed, 3 deletions(-) diff --git a/Items/Armor/TitanHeart/TitanHeartBoots.cs b/Items/Armor/TitanHeart/TitanHeartBoots.cs index 8f557bba6f..ae7ef7e9f4 100644 --- a/Items/Armor/TitanHeart/TitanHeartBoots.cs +++ b/Items/Armor/TitanHeart/TitanHeartBoots.cs @@ -24,7 +24,6 @@ namespace CalamityMod.Items.Armor.TitanHeart player.Calamity().titanHeartBoots = true; player.Calamity().rogueVelocity += 0.1f; player.GetDamage() += 0.04f; - player.GetKnockback() += 0.05f; } public override void AddRecipes() diff --git a/Items/Armor/TitanHeart/TitanHeartMantle.cs b/Items/Armor/TitanHeart/TitanHeartMantle.cs index 6a972d1c89..fbd3c17cd5 100644 --- a/Items/Armor/TitanHeart/TitanHeartMantle.cs +++ b/Items/Armor/TitanHeart/TitanHeartMantle.cs @@ -34,7 +34,6 @@ namespace CalamityMod.Items.Armor.TitanHeart public override void UpdateEquip(Player player) { player.Calamity().titanHeartMantle = true; - player.GetKnockback() += 0.05f; player.GetDamage() += 0.05f; } diff --git a/Items/Armor/TitanHeart/TitanHeartMask.cs b/Items/Armor/TitanHeart/TitanHeartMask.cs index 72638f6fff..03b99c9fa4 100644 --- a/Items/Armor/TitanHeart/TitanHeartMask.cs +++ b/Items/Armor/TitanHeart/TitanHeartMask.cs @@ -41,7 +41,6 @@ namespace CalamityMod.Items.Armor.TitanHeart var modPlayer = player.Calamity(); modPlayer.titanHeartMask = true; player.GetDamage() += 0.05f; - player.GetKnockback() += 0.05f; } public override void AddRecipes() From 6c6e0a863aa9b585986d6a4acb0e6922af8815f2 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <142704082+CongratsIsTrash@users.noreply.github.com> Date: Sun, 9 Mar 2025 01:42:33 -0500 Subject: [PATCH 6/9] Titan Heart set bonus has always lied about its knockback apparently --- Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson index 2976896ad0..5e1106ae0f 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson @@ -534,7 +534,7 @@ TitanHeartMask: { ''' SetBonus: ''' - 10% increased rogue damage and knockback + 10% increased rogue damage and 20% increased rogue knockback +100 maximum stealth Stealth strikes deal double knockback and cause an astral explosion Grants immunity to knockback From 796facb2543098bf24b6a1b7ffc1e2d292887435 Mon Sep 17 00:00:00 2001 From: GinYuH <72181395+GinYuH@users.noreply.github.com> Date: Sat, 8 Mar 2025 23:37:18 -0800 Subject: [PATCH 7/9] Reaper roar pitch down when crippled --- NPCs/Abyss/ReaperShark.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NPCs/Abyss/ReaperShark.cs b/NPCs/Abyss/ReaperShark.cs index 0eed46ccb3..6fb205d54a 100644 --- a/NPCs/Abyss/ReaperShark.cs +++ b/NPCs/Abyss/ReaperShark.cs @@ -115,7 +115,9 @@ namespace CalamityMod.NPCs.Abyss NPC.soundDelay = 360; if (hasBeenHit) { - SoundEngine.PlaySound(EnragedRoarSound, NPC.Center); + // Roar becomes lower pitch when crippled + float pitch = phase3 ? -0.4f : 0; + SoundEngine.PlaySound(EnragedRoarSound with { Pitch = pitch }, NPC.Center); } else { From 81489bca2ce5db0d66f62defb97eb7da22692c31 Mon Sep 17 00:00:00 2001 From: Memes <114233643+Mr-Memes@users.noreply.github.com> Date: Sun, 9 Mar 2025 15:14:55 +0100 Subject: [PATCH 8/9] Fixed Hellkite in MP. --- Items/Weapons/Melee/Hellkite.cs | 9 +- Projectiles/Melee/HellkiteHoldout.cs | 211 +++++++++++++++------------ 2 files changed, 121 insertions(+), 99 deletions(-) diff --git a/Items/Weapons/Melee/Hellkite.cs b/Items/Weapons/Melee/Hellkite.cs index 63fb2fe1a4..e3954b3dff 100644 --- a/Items/Weapons/Melee/Hellkite.cs +++ b/Items/Weapons/Melee/Hellkite.cs @@ -1,9 +1,6 @@ using System.Collections.Generic; -using System.Linq; using CalamityMod.Items.BaseItems; -using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; -using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -45,13 +42,9 @@ namespace CalamityMod.Items.Weapons.Melee } public override bool AltFunctionUse(Player player) => true; public override bool MeleePrefix() => true; - public override void HoldItem(Player player) - { - return; - } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse == 2) + if (player.Calamity().mouseRight) { Projectile.NewProjectile(source, player.MountedCenter, Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, 5); } diff --git a/Projectiles/Melee/HellkiteHoldout.cs b/Projectiles/Melee/HellkiteHoldout.cs index b0fcd9f6c6..4e547a9247 100644 --- a/Projectiles/Melee/HellkiteHoldout.cs +++ b/Projectiles/Melee/HellkiteHoldout.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; @@ -8,7 +9,6 @@ using ReLogic.Content; using ReLogic.Utilities; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.Localization; using Terraria.ModLoader; @@ -45,6 +45,13 @@ namespace CalamityMod.Projectiles.Melee public bool playSwingSound = true; public SlotId AudSlot; + + private bool hasSpawned; + private bool hasHit; + private int damageDone; + private int targetId; + private NPC target => Main.npc[targetId]; + public override void SetDefaults() { base.SetDefaults(); @@ -52,29 +59,104 @@ namespace CalamityMod.Projectiles.Melee Projectile.localNPCHitCooldown = -1; Projectile.DamageType = TrueMeleeDamageClass.Instance; } - public override void OnSpawn(IEntitySource source) - { - CanHit = false; - Projectile.knockBack = 0; - Projectile.scale = 1; - Projectile.ai[1] = -1; - base.OnSpawn(source); - // 14NOV2024: Ozzatron: clamped mouse position unnecessary, as Hellkite has no projectiles - mousePos = Owner.Calamity().mouseWorld; - aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; - useAnim = Owner.itemAnimationMax; - storedUseAnim = useAnim; - - chargeTimerMax = useAnim * 5; // Max charge time is set here - - if (mousePos.X < Owner.Center.X) Owner.direction = -1; - else Owner.direction = 1; - - FlipAsSword = Owner.direction == -1 ? true : false; - } public override void UseStyle() { + if (!hasSpawned) + { + CanHit = false; + Projectile.knockBack = 0; + Projectile.scale = 1; + Projectile.ai[1] = -1; + Projectile.timeLeft = Owner.HeldItem.useAnimation + 1; + + // 14NOV2024: Ozzatron: clamped mouse position unnecessary, as Hellkite has no projectiles + mousePos = Owner.Calamity().mouseWorld; + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + useAnim = Owner.itemAnimationMax; + storedUseAnim = useAnim; + + chargeTimerMax = useAnim * 5; // Max charge time is set here + + if (mousePos.X < Owner.Center.X) Owner.direction = -1; + else Owner.direction = 1; + + FlipAsSword = Owner.direction == -1 ? true : false; + hasSpawned = true; + } + + if (hasHit) + { + // If you are hitting an armored target or kill a target, don't reduce damage based on enemy hits (which uses Projectile.numHits) + if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && pierceReduction > 0) + { + pierceReduction -= 1; + } + + if (!chargedSwing) + { + if (Projectile.numHits == 0) + { + SoundEngine.PlaySound(Hellkite.HitSoundSmall with { Volume = 0.85f, PitchVariance = 0.25f }, Projectile.Center); + Owner.Calamity().GeneralScreenShakePower = 4.5f; + } + for (int i = 0; i < MathHelper.Clamp(8 - Projectile.numHits * 2, 2, 8); i++) + { + Particle spark2 = new LineParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -20).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), false, 40, Main.rand.NextFloat(0.3f, 1f), Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed); + GeneralParticleHandler.SpawnParticle(spark2); + if (Main.rand.NextBool()) + { + Particle spark3 = new AltLineParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -20).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), false, 40, Main.rand.NextFloat(0.3f, 1f), Color.DarkRed); + GeneralParticleHandler.SpawnParticle(spark3); + } + } + } + else + { + if (Projectile.numHits == 0) + { + SoundEngine.PlaySound(Hellkite.HitSoundBig with { Volume = 1f }, Projectile.Center); + Owner.Calamity().GeneralScreenShakePower = 8.5f * GFBMulti; + bool photos = CalamityClientConfig.Instance.Photosensitivity; + + if (!photos) + { + for (int i = 0; i < 3; i++) + { + Particle blastRing = new CustomPulse(target.Center, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 2f * (i + 1) * GFBMulti, 1f, (GFBFlashWarning && !photos) ? (int)(18 * GFBMulti) : 18, true); + GeneralParticleHandler.SpawnParticle(blastRing); + Particle blastRing2 = new CustomPulse(target.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 1f * (i + 1) * GFBMulti, 0.5f, (GFBFlashWarning && !photos) ? (int)(18 * GFBMulti) : 18, true); + GeneralParticleHandler.SpawnParticle(blastRing2); + } + } + + for (int i = 0; i < 2; i++) + { + Particle spark = new GlowSparkParticle(target.Center, (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -25 * (i == 0 ? -1 : 1), false, 12, 0.08f * (photos ? 1f : GFBMulti), Color.OrangeRed, new Vector2(3, 0.8f), true); + GeneralParticleHandler.SpawnParticle(spark); + } + for (int i = 0; i < 15; i++) + { + Particle spark2 = new SparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -40).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), true, 40, Main.rand.NextFloat(0.5f, 1.2f) * GFBMulti, Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed); + GeneralParticleHandler.SpawnParticle(spark2); + if (Main.rand.NextBool()) + { + Particle spark3 = new AltSparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -40).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), true, 40, Main.rand.NextFloat(0.5f, 1.2f) * GFBMulti, Color.DarkRed); + GeneralParticleHandler.SpawnParticle(spark3); + } + Dust dust2 = Dust.NewDustPerfect(target.Center, 278, new Vector2(20, 20).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1)); + dust2.scale = Main.rand.NextFloat(0.55f, 0.85f) * GFBMulti; + dust2.noGravity = true; + dust2.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; + } + } + } + + Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); + target.MoveNPC(launchVel, (chargedSwing ? 24 : 19), true); + hasHit = false; + } + AnimationProgress = Animation % (chargedSwing ? (int)(storedUseAnim * 0.7f) : storedUseAnim); if (Owner.Calamity().mouseRight) @@ -218,7 +300,7 @@ namespace CalamityMod.Projectiles.Melee if ((Owner.Center - aimVel).X < Owner.Center.X) Owner.direction = -1; else Owner.direction = 1; } - + Projectile.rotation = Projectile.rotation.AngleLerp(Owner.AngleTo(mousePos) + MathHelper.ToRadians(45f), 0.1f); if (AnimationProgress < (useAnim / 1.5f)) @@ -332,7 +414,7 @@ namespace CalamityMod.Projectiles.Melee dust2.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; } } - } + } } } @@ -346,73 +428,9 @@ namespace CalamityMod.Projectiles.Melee } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - // If you are hitting an armored target or kill a target, don't reduce damage based on enemy hits (which uses Projectile.numHits) - if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && pierceReduction > 0) - { - pierceReduction -= 1; - } - - if (!chargedSwing) - { - if (Projectile.numHits == 0) - { - SoundEngine.PlaySound(Hellkite.HitSoundSmall with { Volume = 0.85f, PitchVariance = 0.25f }, Projectile.Center); - Owner.Calamity().GeneralScreenShakePower = 4.5f; - } - for (int i = 0; i < MathHelper.Clamp(8 - Projectile.numHits * 2, 2, 8); i++) - { - Particle spark2 = new LineParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -20).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), false, 40, Main.rand.NextFloat(0.3f, 1f), Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed); - GeneralParticleHandler.SpawnParticle(spark2); - if (Main.rand.NextBool()) - { - Particle spark3 = new AltLineParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -20).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), false, 40, Main.rand.NextFloat(0.3f, 1f), Color.DarkRed); - GeneralParticleHandler.SpawnParticle(spark3); - } - } - } - else - { - if (Projectile.numHits == 0) - { - SoundEngine.PlaySound(Hellkite.HitSoundBig with { Volume = 1f }, Projectile.Center); - Owner.Calamity().GeneralScreenShakePower = 8.5f * GFBMulti; - bool photos = CalamityClientConfig.Instance.Photosensitivity; - - if (!photos) - { - for (int i = 0; i < 3; i++) - { - Particle blastRing = new CustomPulse(target.Center, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 2f * (i + 1) * GFBMulti, 1f, (GFBFlashWarning && !photos) ? (int)(18 * GFBMulti) : 18, true); - GeneralParticleHandler.SpawnParticle(blastRing); - Particle blastRing2 = new CustomPulse(target.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 1f * (i + 1) * GFBMulti, 0.5f, (GFBFlashWarning && !photos) ? (int)(18 * GFBMulti) : 18, true); - GeneralParticleHandler.SpawnParticle(blastRing2); - } - } - - for (int i = 0; i < 2; i++) - { - Particle spark = new GlowSparkParticle(target.Center, (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -25 * (i == 0 ? -1 : 1), false, 12, 0.08f * (photos ? 1f : GFBMulti), Color.OrangeRed, new Vector2(3, 0.8f), true); - GeneralParticleHandler.SpawnParticle(spark); - } - for (int i = 0; i < 15; i++) - { - Particle spark2 = new SparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -40).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), true, 40, Main.rand.NextFloat(0.5f, 1.2f) * GFBMulti, Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed); - GeneralParticleHandler.SpawnParticle(spark2); - if (Main.rand.NextBool()) - { - Particle spark3 = new AltSparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -40).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), true, 40, Main.rand.NextFloat(0.5f, 1.2f) * GFBMulti, Color.DarkRed); - GeneralParticleHandler.SpawnParticle(spark3); - } - Dust dust2 = Dust.NewDustPerfect(target.Center, 278, new Vector2(20, 20).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1)); - dust2.scale = Main.rand.NextFloat(0.55f, 0.85f) * GFBMulti; - dust2.noGravity = true; - dust2.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; - } - } - } - - Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - target.MoveNPC(launchVel, (chargedSwing ? 24 : 19), true); + targetId = target.whoAmI; + this.damageDone = damageDone; + Projectile.ForceNetUpdate(); } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { @@ -462,8 +480,19 @@ namespace CalamityMod.Projectiles.Melee } return false; } - public override void ResetStyle() + + public override void SendExtraAI(BinaryWriter writer) { + writer.Write7BitEncodedInt(targetId); + writer.Write(damageDone); + writer.Write(hasHit); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + targetId = reader.Read7BitEncodedInt(); + damageDone = reader.ReadInt32(); + hasHit = reader.ReadBoolean(); } } } From cae350130db877d59a14476f4866d7d8cdcce958 Mon Sep 17 00:00:00 2001 From: Memes <114233643+Mr-Memes@users.noreply.github.com> Date: Sun, 9 Mar 2025 23:37:38 +0100 Subject: [PATCH 9/9] Some errors in the MP syncing fixed. --- Projectiles/Melee/GrandDadHoldout.cs | 115 +++++++++++++++------------ Projectiles/Melee/HellkiteHoldout.cs | 111 ++++++++++++++------------ 2 files changed, 124 insertions(+), 102 deletions(-) diff --git a/Projectiles/Melee/GrandDadHoldout.cs b/Projectiles/Melee/GrandDadHoldout.cs index f011482728..22ee0898d6 100644 --- a/Projectiles/Melee/GrandDadHoldout.cs +++ b/Projectiles/Melee/GrandDadHoldout.cs @@ -88,68 +88,79 @@ namespace CalamityMod.Projectiles.Melee */ if (hasHit) { - if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Projectile.numHits > 0) - Projectile.numHits -= 1; + int numHits = 0; + foreach (var target in Main.ActiveNPCs) + { + Vector2 cen = Projectile.Center + new Vector2(HitboxOutset, 0).RotatedBy(FinalRotation + HitboxRotationOffset); + Rectangle hitbox = new((int)cen.X - (int)(HitboxSize.X / 2), (int)cen.Y - (int)(HitboxSize.Y / 2), (int)HitboxSize.X, (int)HitboxSize.Y); + if (!hitbox.Intersects(target.getRect())) + continue; + + if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && numHits > 0) + numHits -= 1; - SoundStyle fire = new("CalamityMod/Sounds/NPCHit/ThanatosHitOpen1"); - SoundEngine.PlaySound(fire with { Volume = 0.75f, Pitch = -0.1f }, Projectile.Center); - SoundStyle fire2 = new("CalamityMod/Sounds/Item/FinalDawnSlash"); - SoundEngine.PlaySound(fire2 with { Volume = 0.65f, Pitch = Main.rand.NextFloat(-0.2f, -0.3f) }, Projectile.Center); - if (Main.zenithWorld && Projectile.numHits == 0 && target.type != ModContent.NPCType() && Main.rand.NextBool(5)) - { - SoundStyle fire3 = new("CalamityMod/Sounds/Item/GFBScreams/Scream", 8); - SoundEngine.PlaySound(fire3 with { Volume = 0.8f }, Projectile.Center); - } - if (Projectile.numHits == 0) - { - Owner.Calamity().GeneralScreenShakePower = 6.5f; - } - - int heal = (int)MathHelper.Clamp(20 - Projectile.numHits * 12, 1, 20); - if (Projectile.numHits < 10) - { - Owner.HealPlayer(heal); - } - - if (target.CanBeMoved(true) || Main.zenithWorld || target.type == ModContent.NPCType() || (DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs)) - { - if (target.type == ModContent.NPCType()) + SoundStyle fire = new("CalamityMod/Sounds/NPCHit/ThanatosHitOpen1"); + SoundEngine.PlaySound(fire with { Volume = 0.75f, Pitch = -0.1f }, Projectile.Center); + SoundStyle fire2 = new("CalamityMod/Sounds/Item/FinalDawnSlash"); + SoundEngine.PlaySound(fire2 with { Volume = 0.65f, Pitch = Main.rand.NextFloat(-0.2f, -0.3f) }, Projectile.Center); + if (Main.zenithWorld && numHits == 0 && target.type != ModContent.NPCType() && Main.rand.NextBool(5)) { - CombatText.NewText(target.Hitbox, Color.Aqua, CalamityUtils.GetTextValue("Misc.HecBoop")); - SoundStyle boop = new("CalamityMod/Sounds/Item/SnootBooped"); - SoundEngine.PlaySound(boop with { Pitch = Main.rand.NextFloat(-0.15f, 0.15f) }, Projectile.Center); + SoundStyle fire3 = new("CalamityMod/Sounds/Item/GFBScreams/Scream", 8); + SoundEngine.PlaySound(fire3 with { Volume = 0.8f }, Projectile.Center); + } + if (numHits == 0) + { + Owner.Calamity().GeneralScreenShakePower = 6.5f; } - bool rightClicked = Owner.Calamity().mouseRight; + int heal = (int)MathHelper.Clamp(20 - numHits * 12, 1, 20); + if (numHits < 10) + { + Owner.HealPlayer(heal); + } - // Make all hit enemies able to hit tiles, so you can dunk them - target.noTileCollide = false; + if (target.CanBeMoved(true) || Main.zenithWorld || target.type == ModContent.NPCType() || (DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs)) + { + if (target.type == ModContent.NPCType()) + { + CombatText.NewText(target.Hitbox, Color.Aqua, CalamityUtils.GetTextValue("Misc.HecBoop")); + SoundStyle boop = new("CalamityMod/Sounds/Item/SnootBooped"); + SoundEngine.PlaySound(boop with { Pitch = Main.rand.NextFloat(-0.15f, 0.15f) }, Projectile.Center); + } - // Launch the suckers - Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - float launchPower = (Main.zenithWorld ? 50 : 30) * (rightClicked ? 2 : 1); - target.MoveNPC(launchVel, launchPower * 0.5f, true); + bool rightClicked = Owner.Calamity().mouseRight; - // Remove knockback resist, just like it used to - target.knockBackResist = 1; + // Make all hit enemies able to hit tiles, so you can dunk them + target.noTileCollide = false; - // Apply tile collison damage (is bonus on GFB and even further is both final bosses are gone) - target.FlungNPC().ApplyCollisionDamage(target, Owner, Projectile.damage * (Main.zenithWorld ? (DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs ? 1000 : 77) : 3) * (rightClicked ? 3 : 1), launchVel * launchPower, 5f, true); - } + // Launch the suckers + Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); + float launchPower = (Main.zenithWorld ? 50 : 30) * (rightClicked ? 2 : 1); + target.MoveNPC(launchVel, launchPower * 0.5f, true); - if (Projectile.numHits < 3) - { - Particle spark = new VoidSparkParticle(target.Center, (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * (-45 + Projectile.numHits * 5), false, (int)(16 - Projectile.numHits * 3), 0.6f - Projectile.numHits * 0.15f, Color.DodgerBlue, 0.45f); - GeneralParticleHandler.SpawnParticle(spark); - } + // Remove knockback resist, just like it used to + target.knockBackResist = 1; - for (int i = 0; i < MathHelper.Clamp(10 - Projectile.numHits * 2, 2, 10); i++) - { - Particle spark2 = new SparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -35).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), false, 55, Main.rand.NextFloat(0.4f, 1.5f), Main.rand.NextBool(4) ? Color.DodgerBlue : Color.Blue); - GeneralParticleHandler.SpawnParticle(spark2); - Dust dust = Dust.NewDustPerfect(target.Center, ModContent.DustType(), ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -35).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), 0, default, Main.rand.NextFloat(1.55f, 2.2f)); - dust.noGravity = true; - dust.color = Main.rand.NextBool() ? Color.DodgerBlue : Color.Blue; + // Apply tile collison damage (is bonus on GFB and even further is both final bosses are gone) + target.FlungNPC().ApplyCollisionDamage(target, Owner, Projectile.damage * (Main.zenithWorld ? (DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs ? 1000 : 77) : 3) * (rightClicked ? 3 : 1), launchVel * launchPower, 5f, true); + } + + if (numHits < 3) + { + Particle spark = new VoidSparkParticle(target.Center, (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * (-45 + numHits * 5), false, (int)(16 - numHits * 3), 0.6f - numHits * 0.15f, Color.DodgerBlue, 0.45f); + GeneralParticleHandler.SpawnParticle(spark); + } + + for (int i = 0; i < MathHelper.Clamp(10 - numHits * 2, 2, 10); i++) + { + Particle spark2 = new SparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -35).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), false, 55, Main.rand.NextFloat(0.4f, 1.5f), Main.rand.NextBool(4) ? Color.DodgerBlue : Color.Blue); + GeneralParticleHandler.SpawnParticle(spark2); + Dust dust = Dust.NewDustPerfect(target.Center, ModContent.DustType(), ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -35).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), 0, default, Main.rand.NextFloat(1.55f, 2.2f)); + dust.noGravity = true; + dust.color = Main.rand.NextBool() ? Color.DodgerBlue : Color.Blue; + } + + numHits++; } hasHit = false; diff --git a/Projectiles/Melee/HellkiteHoldout.cs b/Projectiles/Melee/HellkiteHoldout.cs index 4e547a9247..84549b7c86 100644 --- a/Projectiles/Melee/HellkiteHoldout.cs +++ b/Projectiles/Melee/HellkiteHoldout.cs @@ -87,73 +87,84 @@ namespace CalamityMod.Projectiles.Melee if (hasHit) { - // If you are hitting an armored target or kill a target, don't reduce damage based on enemy hits (which uses Projectile.numHits) - if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && pierceReduction > 0) + int numHits = 0; + foreach (var target in Main.ActiveNPCs) { - pierceReduction -= 1; - } + Vector2 cen = Projectile.Center + new Vector2(HitboxOutset, 0).RotatedBy(FinalRotation + HitboxRotationOffset); + Rectangle hitbox = new((int)cen.X - (int)(HitboxSize.X / 2), (int)cen.Y - (int)(HitboxSize.Y / 2), (int)HitboxSize.X, (int)HitboxSize.Y); + if (!hitbox.Intersects(target.getRect())) + continue; - if (!chargedSwing) - { - if (Projectile.numHits == 0) + // If you are hitting an armored target or kill a target, don't reduce damage based on enemy hits (which uses Projectile.numHits) + if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && pierceReduction > 0) { - SoundEngine.PlaySound(Hellkite.HitSoundSmall with { Volume = 0.85f, PitchVariance = 0.25f }, Projectile.Center); - Owner.Calamity().GeneralScreenShakePower = 4.5f; + pierceReduction -= 1; } - for (int i = 0; i < MathHelper.Clamp(8 - Projectile.numHits * 2, 2, 8); i++) - { - Particle spark2 = new LineParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -20).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), false, 40, Main.rand.NextFloat(0.3f, 1f), Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed); - GeneralParticleHandler.SpawnParticle(spark2); - if (Main.rand.NextBool()) - { - Particle spark3 = new AltLineParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -20).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), false, 40, Main.rand.NextFloat(0.3f, 1f), Color.DarkRed); - GeneralParticleHandler.SpawnParticle(spark3); - } - } - } - else - { - if (Projectile.numHits == 0) - { - SoundEngine.PlaySound(Hellkite.HitSoundBig with { Volume = 1f }, Projectile.Center); - Owner.Calamity().GeneralScreenShakePower = 8.5f * GFBMulti; - bool photos = CalamityClientConfig.Instance.Photosensitivity; - if (!photos) + if (!chargedSwing) + { + if (numHits == 0) { - for (int i = 0; i < 3; i++) - { - Particle blastRing = new CustomPulse(target.Center, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 2f * (i + 1) * GFBMulti, 1f, (GFBFlashWarning && !photos) ? (int)(18 * GFBMulti) : 18, true); - GeneralParticleHandler.SpawnParticle(blastRing); - Particle blastRing2 = new CustomPulse(target.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 1f * (i + 1) * GFBMulti, 0.5f, (GFBFlashWarning && !photos) ? (int)(18 * GFBMulti) : 18, true); - GeneralParticleHandler.SpawnParticle(blastRing2); - } + SoundEngine.PlaySound(Hellkite.HitSoundSmall with { Volume = 0.85f, PitchVariance = 0.25f }, Projectile.Center); + Owner.Calamity().GeneralScreenShakePower = 4.5f; } - - for (int i = 0; i < 2; i++) + for (int i = 0; i < MathHelper.Clamp(8 - numHits * 2, 2, 8); i++) { - Particle spark = new GlowSparkParticle(target.Center, (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -25 * (i == 0 ? -1 : 1), false, 12, 0.08f * (photos ? 1f : GFBMulti), Color.OrangeRed, new Vector2(3, 0.8f), true); - GeneralParticleHandler.SpawnParticle(spark); - } - for (int i = 0; i < 15; i++) - { - Particle spark2 = new SparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -40).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), true, 40, Main.rand.NextFloat(0.5f, 1.2f) * GFBMulti, Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed); + Particle spark2 = new LineParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -20).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), false, 40, Main.rand.NextFloat(0.3f, 1f), Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed); GeneralParticleHandler.SpawnParticle(spark2); if (Main.rand.NextBool()) { - Particle spark3 = new AltSparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -40).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), true, 40, Main.rand.NextFloat(0.5f, 1.2f) * GFBMulti, Color.DarkRed); + Particle spark3 = new AltLineParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -20).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), false, 40, Main.rand.NextFloat(0.3f, 1f), Color.DarkRed); GeneralParticleHandler.SpawnParticle(spark3); } - Dust dust2 = Dust.NewDustPerfect(target.Center, 278, new Vector2(20, 20).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1)); - dust2.scale = Main.rand.NextFloat(0.55f, 0.85f) * GFBMulti; - dust2.noGravity = true; - dust2.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; } } + else + { + if (numHits == 0) + { + SoundEngine.PlaySound(Hellkite.HitSoundBig with { Volume = 1f }, Projectile.Center); + Owner.Calamity().GeneralScreenShakePower = 8.5f * GFBMulti; + bool photos = CalamityClientConfig.Instance.Photosensitivity; + + if (!photos) + { + for (int i = 0; i < 3; i++) + { + Particle blastRing = new CustomPulse(target.Center, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 2f * (i + 1) * GFBMulti, 1f, (GFBFlashWarning && !photos) ? (int)(18 * GFBMulti) : 18, true); + GeneralParticleHandler.SpawnParticle(blastRing); + Particle blastRing2 = new CustomPulse(target.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 1f * (i + 1) * GFBMulti, 0.5f, (GFBFlashWarning && !photos) ? (int)(18 * GFBMulti) : 18, true); + GeneralParticleHandler.SpawnParticle(blastRing2); + } + } + + for (int i = 0; i < 2; i++) + { + Particle spark = new GlowSparkParticle(target.Center, (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -25 * (i == 0 ? -1 : 1), false, 12, 0.08f * (photos ? 1f : GFBMulti), Color.OrangeRed, new Vector2(3, 0.8f), true); + GeneralParticleHandler.SpawnParticle(spark); + } + for (int i = 0; i < 15; i++) + { + Particle spark2 = new SparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -40).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), true, 40, Main.rand.NextFloat(0.5f, 1.2f) * GFBMulti, Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed); + GeneralParticleHandler.SpawnParticle(spark2); + if (Main.rand.NextBool()) + { + Particle spark3 = new AltSparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -40).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), true, 40, Main.rand.NextFloat(0.5f, 1.2f) * GFBMulti, Color.DarkRed); + GeneralParticleHandler.SpawnParticle(spark3); + } + Dust dust2 = Dust.NewDustPerfect(target.Center, 278, new Vector2(20, 20).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1)); + dust2.scale = Main.rand.NextFloat(0.55f, 0.85f) * GFBMulti; + dust2.noGravity = true; + dust2.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; + } + } + } + + Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); + target.MoveNPC(launchVel, (chargedSwing ? 24 : 19), true); + numHits++; } - Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - target.MoveNPC(launchVel, (chargedSwing ? 24 : 19), true); hasHit = false; }