diff --git a/Balancing/BalancingChangesManager.cs b/Balancing/BalancingChangesManager.cs index 7bfd3ae188..cbe93a7b4b 100644 --- a/Balancing/BalancingChangesManager.cs +++ b/Balancing/BalancingChangesManager.cs @@ -157,6 +157,15 @@ namespace CalamityMod.Balancing // 50% resist to Dormant Brimseeker. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + // 50% resist to Aftershock Rocks. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + + // 50% resist to Avalanche Ice Bombs. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + + // 50% resist to Avalanche Frost Shards. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + // 45% resist to Mounted Scanner. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.55f, ProjectileType())))); diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index 763d2543b0..f118b46064 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -93,7 +93,6 @@ namespace CalamityMod.ILEditing // Damage and health balance On_Main.DamageVar_float_int_float += AdjustDamageVariance; IL_NPC.ScaleStats_ApplyExpertTweaks += RemoveExpertHardmodeScaling; - IL_Projectile.AI_001 += AdjustChlorophyteBullets; IL_Projectile.AI_099_2 += LimitTerrarianProjectiles; IL_Player.UpdateBuffs += NerfSharpeningStation; IL_Player.UpdateBuffs += NerfBeetleScaleMail; diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index 33712995f1..81a209872d 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -1186,26 +1186,6 @@ namespace CalamityMod.ILEditing } #endregion - #region Chlorophyte Bullet Dust Reducing - private static void AdjustChlorophyteBullets(ILContext il) - { - // Reduce dust from 10 to 5 and homing range. - var cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(ProjectileID.ChlorophyteBullet))) - { - LogFailure("Chlorophyte Bullet AI", "Could not locate the bullet ID."); - return; - } - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(10))) // The number of dust spawned by the bullet. - { - LogFailure("Chlorophyte Bullet AI", "Could not locate the dust quantity."); - return; - } - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_I4_5); // Decrease dust to 5. - } - #endregion - #region Make Tax Collector Worth it private static void MakeTaxCollectorUseful(ILContext il) { diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 400164f9c9..67f7ef1f85 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -1031,7 +1031,7 @@ namespace CalamityMod.Items } else if (set == "SpectreHealing") { - player.GetDamage() += 0.2f; + player.GetDamage() += 0.4f; player.setBonus = CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.SpectreHealing"); } else if (set == "SolarFlare") diff --git a/Items/Weapons/Melee/DefiledGreatsword.cs b/Items/Weapons/Melee/DefiledGreatsword.cs index 553a00f073..402654d4b3 100644 --- a/Items/Weapons/Melee/DefiledGreatsword.cs +++ b/Items/Weapons/Melee/DefiledGreatsword.cs @@ -14,6 +14,7 @@ namespace CalamityMod.Items.Weapons.Melee public class DefiledGreatsword : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; + public override void SetDefaults() { Item.width = 102; diff --git a/Items/Weapons/Melee/GrandGuardian.cs b/Items/Weapons/Melee/GrandGuardian.cs index 9bf3b77545..19fda8eb53 100644 --- a/Items/Weapons/Melee/GrandGuardian.cs +++ b/Items/Weapons/Melee/GrandGuardian.cs @@ -10,6 +10,13 @@ namespace CalamityMod.Items.Weapons.Melee public class GrandGuardian : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; + + internal const int TotalHealOrbs = 3; + + internal const int HealPerOrb = 3; + + internal const int TotalHealed = TotalHealOrbs * HealPerOrb; + public override void SetDefaults() { Item.width = 130; @@ -72,31 +79,27 @@ namespace CalamityMod.Items.Weapons.Melee if (targetLife <= (targetMaxLife * 0.5f) && player.ownedProjectileCounts[ModContent.ProjectileType()] < 3) { - float randomSpeedX = Main.rand.Next(6, 13); - float randomSpeedY = Main.rand.Next(6, 13); + float randomSpeedX = Main.rand.NextFloat(6f, 12f); + float randomSpeedY = Main.rand.NextFloat(6f, 12f); Projectile.NewProjectile(source, targetPos.X, targetPos.Y, -randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), rainBoltDamage, knockback, player.whoAmI); Projectile.NewProjectile(source, targetPos.X, targetPos.Y, randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), rainBoltDamage, knockback, player.whoAmI); Projectile.NewProjectile(source, targetPos.X, targetPos.Y, 0f, -randomSpeedY, ModContent.ProjectileType(), rainBoltDamage, knockback, player.whoAmI); } - if (targetLife <= 0 && !player.moonLeech && player.ownedProjectileCounts[ModContent.ProjectileType()] < 3) + + if (player.moonLeech || player.lifeSteal <= 0f) + return; + + if (targetLife <= 0 && !player.moonLeech && player.ownedProjectileCounts[ModContent.ProjectileType()] < 3 && targetMaxLife > 5) { - float randomSpeedX = Main.rand.Next(3, 7); - float randomSpeedY = Main.rand.Next(3, 7); + player.lifeSteal -= TotalHealed; + float randomSpeedX = Main.rand.NextFloat(3f, 4.5f); + float randomSpeedY = Main.rand.NextFloat(3f, 4.5f); Projectile.NewProjectile(source, targetPos.X, targetPos.Y, -randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), 0, 0f, player.whoAmI); Projectile.NewProjectile(source, targetPos.X, targetPos.Y, randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), 0, 0f, player.whoAmI); Projectile.NewProjectile(source, targetPos.X, targetPos.Y, 0f, -randomSpeedY, ModContent.ProjectileType(), 0, 0f, player.whoAmI); } } - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.NextBool(3)) - { - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, DustID.RainbowTorch, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[dust].noGravity = true; - } - } - public override void AddRecipes() { CreateRecipe(). diff --git a/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson index f4be576792..7e3d9b1bd6 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson @@ -165,7 +165,7 @@ SetBonus: { ''' SpectreHealing: ''' - Reduces Magic damage by 20% and converts it to healing force + Converts magic damage to healing force Magic damage done to enemies heals the player with lowest health ''' } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 2b9ca6b40e..c9b1eec753 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -3214,7 +3214,7 @@ namespace CalamityMod.NPCs if (CalamityLists.AstrumDeusIDs.Contains(npc.type)) modifiers.FinalDamage *= 1f - MathHelper.Lerp(0f, 0.99f, MathHelper.Clamp(1f - newAI[1] / (newAI[0] != 0f ? 300f : 600f), 0f, 1f)); if (eaterofWorldsResist) - modifiers.FinalDamage *= 0.01f; + modifiers.FinalDamage *= 0.05f; } // Directly modifies final damage incoming to an NPC based on their DR (damage reduction) stat added by Calamity. diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs index 7398b37954..352444b2f2 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs @@ -631,7 +631,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // Move closer bool canHitTarget = Collision.CanHit(NPC.Center, 1, 1, player.position, player.width, player.height); - float distanceAboveTarget = !canHitTarget ? 0f : 560f; + float distanceAboveTarget = !canHitTarget ? 0f : 400f; float distanceAwayFromTargetX = !canHitTarget ? 36f : 144f; float distanceAwayFromTargetY = player.Center.Y - NPC.Center.Y; float distanceAwayFromTargetYLeeway = !canHitTarget ? 16f : 48f; @@ -714,7 +714,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath } // Move closer - float distanceAboveTarget = !canHitTarget ? 0f : 560f; + float distanceAboveTarget = !canHitTarget ? 0f : 400f; float distanceAwayFromTargetX = !canHitTarget ? 36f : 144f; float distanceAwayFromTargetY = player.Center.Y - NPC.Center.Y; float distanceAwayFromTargetYLeeway = !canHitTarget ? 16f : 48f; @@ -803,7 +803,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath } // Move closer - float distanceAboveTarget = !canHitTarget ? 0f : 560f; + float distanceAboveTarget = !canHitTarget ? 0f : 400f; float distanceAwayFromTargetX = !canHitTarget ? 36f : 144f; float distanceAwayFromTargetY = player.Center.Y - NPC.Center.Y; float distanceAwayFromTargetYLeeway = !canHitTarget ? 16f : 48f; @@ -895,7 +895,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath } // Move closer - float distanceAboveTarget = !canHitTarget ? 0f : 560f; + float distanceAboveTarget = !canHitTarget ? 0f : 400f; float distanceAwayFromTargetX = !canHitTarget ? 36f : 144f; float distanceAwayFromTargetY = player.Center.Y - NPC.Center.Y; float distanceAwayFromTargetYLeeway = !canHitTarget ? 16f : 48f; diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index df67e8f9db..d17474650f 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -1432,6 +1432,105 @@ namespace CalamityMod.Projectiles return false; } + else if (projectile.type == ProjectileID.ChlorophyteBullet) + { + if (projectile.alpha < 170) + { + int totalDust = 5; + for (int i = 0; i < totalDust; i++) + { + float x2 = projectile.position.X - projectile.velocity.X / (float)totalDust * (float)i; + float y2 = projectile.position.Y - projectile.velocity.Y / (float)totalDust * (float)i; + int dust = Dust.NewDust(new Vector2(x2, y2), 1, 1, 75); + Main.dust[dust].alpha = projectile.alpha; + Main.dust[dust].position.X = x2; + Main.dust[dust].position.Y = y2; + Main.dust[dust].velocity *= 0f; + Main.dust[dust].noGravity = true; + } + } + + float velocityLength = (float)Math.Sqrt(projectile.velocity.X * projectile.velocity.X + projectile.velocity.Y * projectile.velocity.Y); + float cachedVelocityLength = projectile.localAI[0]; + if (cachedVelocityLength == 0f) + { + projectile.localAI[0] = velocityLength; + cachedVelocityLength = velocityLength; + } + + if (projectile.alpha > 0) + projectile.alpha -= 25; + + if (projectile.alpha < 0) + projectile.alpha = 0; + + float posX = projectile.position.X; + float posY = projectile.position.Y; + float homingDistance = 300f; + bool homeIn = false; + int target = 0; + if (projectile.ai[1] == 0f) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(this) && (projectile.ai[1] == 0f || projectile.ai[1] == (float)(i + 1))) + { + float targetCenterX = Main.npc[i].Center.X; + float targetCenterY = Main.npc[i].Center.Y; + float targetDistance = Math.Abs(projectile.Center.X - targetCenterX) + Math.Abs(projectile.Center.Y - targetCenterY); + if (targetDistance < homingDistance && Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height)) + { + homingDistance = targetDistance; + posX = targetCenterX; + posY = targetCenterY; + homeIn = true; + target = i; + } + } + } + + if (homeIn) + projectile.ai[1] = target + 1; + + homeIn = false; + } + + if (projectile.ai[1] > 0f) + { + int targetIndex = (int)(projectile.ai[1] - 1f); + if (Main.npc[targetIndex].active && Main.npc[targetIndex].CanBeChasedBy(this, ignoreDontTakeDamage: true) && !Main.npc[targetIndex].dontTakeDamage) + { + float targetCenterX = Main.npc[targetIndex].Center.X; + float targetCenterY = Main.npc[targetIndex].Center.Y; + float homingCutOffDistance = 1000f; + if (Math.Abs(projectile.Center.X - targetCenterX) + Math.Abs(projectile.Center.Y - targetCenterY) < homingCutOffDistance) + { + homeIn = true; + posX = Main.npc[targetIndex].Center.X; + posY = Main.npc[targetIndex].Center.Y; + } + } + else + projectile.ai[1] = 0f; + } + + if (!projectile.friendly) + homeIn = false; + + if (homeIn) + { + int inertia = 8; + float homingSpeed = cachedVelocityLength; + Vector2 destination = new Vector2(posX, posY); + Vector2 homeDirection = (destination - projectile.Center).SafeNormalize(Vector2.UnitY); + projectile.velocity = (projectile.velocity * inertia + homeDirection * homingSpeed) / (inertia + 1f); + } + + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + + return false; + } + // Adjust dust to avoid lag. else if (projectile.type == ProjectileID.VampireHeal) { diff --git a/Projectiles/Healing/RainHeal.cs b/Projectiles/Healing/RainHeal.cs index 77fd20cb64..4b72eba2a6 100644 --- a/Projectiles/Healing/RainHeal.cs +++ b/Projectiles/Healing/RainHeal.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Items.Weapons.Melee; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,37 +9,42 @@ namespace CalamityMod.Projectiles.Healing public class RainHeal : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Healing"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + private const int TimeLeft = 300; + + private const int HomingTime = TimeLeft - 120; + + private const int SlowDownTime = TimeLeft - 150; + public override void SetDefaults() { Projectile.width = 4; Projectile.height = 4; Projectile.friendly = true; Projectile.ignoreWater = true; - Projectile.alpha = 255; Projectile.penetrate = 1; - Projectile.timeLeft = 180; + Projectile.timeLeft = TimeLeft; Projectile.tileCollide = false; + Projectile.extraUpdates = 3; } public override void AI() { - if (Projectile.timeLeft < 165) + if (Projectile.timeLeft < HomingTime) { - if (Projectile.timeLeft > 150) + if (Projectile.timeLeft > SlowDownTime) Projectile.velocity *= 0.9f; else - Projectile.HealingProjectile(8, Projectile.owner, 12f, 15f, false); + Projectile.HealingProjectile(GrandGuardian.HealPerOrb, Projectile.owner, 12f, 15f); } - float dustX = Projectile.velocity.X * 0.2f; - float dustY = -(Projectile.velocity.Y * 0.2f); - int rainbow = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowTorch, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Dust dust = Main.dust[rainbow]; - dust.noGravity = true; - dust.position.X -= dustX; - dust.position.Y -= dustY; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowTorch, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB)); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0f; + Main.dust[dust].position.X -= Projectile.velocity.X * 0.2f; + Main.dust[dust].position.Y += Projectile.velocity.Y * 0.2f; } } } diff --git a/Projectiles/Melee/RainBolt.cs b/Projectiles/Melee/RainBolt.cs index dded261f56..f5dac61a82 100644 --- a/Projectiles/Melee/RainBolt.cs +++ b/Projectiles/Melee/RainBolt.cs @@ -3,13 +3,19 @@ using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Melee { public class RainBolt : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + private const int TimeLeft = 180; + + private const int HomingTime = TimeLeft - 30; + public override void SetDefaults() { Projectile.width = 10; @@ -17,10 +23,10 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; Projectile.penetrate = 1; - Projectile.timeLeft = 180; + Projectile.timeLeft = TimeLeft; } - public override bool? CanHitNPC(NPC target) => Projectile.timeLeft < 150 && target.CanBeChasedBy(Projectile); + public override bool? CanHitNPC(NPC target) => Projectile.timeLeft < HomingTime && target.CanBeChasedBy(Projectile); public override void AI() { @@ -34,7 +40,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[rainbow].noGravity = true; Main.dust[rainbow].velocity *= 0f; - if (Projectile.timeLeft < 150) + if (Projectile.timeLeft < HomingTime) CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 600f, 12f, 20f); else Projectile.velocity *= 0.95f; @@ -45,9 +51,8 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(SoundID.Item60, Projectile.Center); for (int k = 0; k < 5; k++) { - int rain = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.RainbowTorch, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB)); + int rain = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.RainbowTorch, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB)); Main.dust[rain].noGravity = true; - Main.dust[rain].velocity *= 4f; } } } diff --git a/Projectiles/Melee/RainbowBoom.cs b/Projectiles/Melee/RainbowBoom.cs index a5bfc69ab9..bb7eda7abd 100644 --- a/Projectiles/Melee/RainbowBoom.cs +++ b/Projectiles/Melee/RainbowBoom.cs @@ -9,6 +9,7 @@ namespace CalamityMod.Projectiles.Melee public class RainbowBoom : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetDefaults() @@ -27,38 +28,16 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - bool xflag = false; - bool yflag = false; - if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) - { - xflag = true; - } - if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) - { - xflag = true; - } - if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) - { - yflag = true; - } - if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) - { - yflag = true; - } - if (xflag && yflag) - { - Projectile.Kill(); - } float projTimer = 25f; if (Projectile.ai[0] > 180f) - { projTimer -= (Projectile.ai[0] - 180f) / 2f; - } + if (projTimer <= 0f) { projTimer = 0f; Projectile.Kill(); } + projTimer *= 0.7f; Projectile.ai[0] += 4f; int timerCounter = 0; @@ -75,19 +54,12 @@ namespace CalamityMod.Projectiles.Melee Main.dust[rainbow].noGravity = true; Main.dust[rainbow].position.X = Projectile.Center.X; Main.dust[rainbow].position.Y = Projectile.Center.Y; - Dust expr_149DF_cp_0 = Main.dust[rainbow]; - expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11); - Dust expr_14A09_cp_0 = Main.dust[rainbow]; - expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11); + Main.dust[rainbow].position.X += (float)Main.rand.Next(-10, 11); + Main.dust[rainbow].position.Y += (float)Main.rand.Next(-10, 11); Main.dust[rainbow].velocity.X = rando1; Main.dust[rainbow].velocity.Y = rando2; timerCounter++; } } - - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - Projectile.damage = (int)(Projectile.damage * 0.9); - } } }