diff --git a/Balancing/BalancingChangesManager.cs b/Balancing/BalancingChangesManager.cs index afd4d332ee..e357f081a4 100644 --- a/Balancing/BalancingChangesManager.cs +++ b/Balancing/BalancingChangesManager.cs @@ -171,9 +171,6 @@ namespace CalamityMod.Balancing // 50% resist to Aftershock's rocks. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); - // 50% resist to Avalanche's Ice Bombs and shards. - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType(), ProjectileType())))); - // 50% resist to Dormant Brimseeker. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); @@ -183,6 +180,9 @@ namespace CalamityMod.Balancing // 30% resist to Meowthrower. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); + // 25% resist to Avalanche's Ice Bombs and shards. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType(), ProjectileType())))); + // 25% resist to SHPC. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index 5e05f4eabd..2cf0c90e80 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -193,6 +193,7 @@ namespace CalamityMod.ILEditing IL_Main.UpdateTime_StartNight += BloodMoonsRequire200MaxLife; IL_WorldGen.AttemptFossilShattering += PreventFossilShattering; On_Player.GetPickaxeDamage += RemoveHellforgePickaxeRequirement; + IL_Player.Update += PreventUFODismountInWater; On_Player.GetAnglerReward += ImproveAnglerRewards; On_Player.ItemCheck_CheckCanUse += RemoveCelestialSigilUseLock; diff --git a/ILEditing/VanillaStupidityFixingILChanges.cs b/ILEditing/VanillaStupidityFixingILChanges.cs index 88e296f0c8..510c5dd121 100644 --- a/ILEditing/VanillaStupidityFixingILChanges.cs +++ b/ILEditing/VanillaStupidityFixingILChanges.cs @@ -276,6 +276,37 @@ namespace CalamityMod.ILEditing // TODO -- Finish this #endregion Fix Chlorophyte Crystal Attacking Where it Shouldn't + #region Prevent UFO Mount from Dismounting in Water + private static void PreventUFODismountInWater(ILContext il) + { + // Prevent the Cosmic Car Key's UFO mount from dismounting when the player is in water. + var cursor = new ILCursor(il); + + // Unfortunately, the code responsible for this is 4000 lines into Player.Update, meaning that reaching it is far from simple. + // The following method was the easiest way I could find to reach it: + // Move to the third call of Mount.Dismount. + for (int i = 0; i < 3; i++) + { + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchCallvirt("Dismount"))) + { + LogFailure("Prevent UFO Dismounting in Water", "Could not reach the Dismount instruction."); + return; + } + } + // Move the cursor backwards to place it right after the instruction which loads Main.myPlayer onto the stack. + if (!cursor.TryGotoPrev(MoveType.After, i => i.MatchLdsfld
("myPlayer"))) + { + LogFailure("Prevent UFO Dismounting in Water", "Could not locate the myPlayer check."); + return; + } + + // Remove the instruction and replace it with the integer limit. The next instruction checks if this value is equal to Player.whoAmI. + // Player.whoAmI will never be the integer limit, so the check will always fail and the UFO will not dismount. + cursor.EmitPop(); + cursor.Emit(OpCodes.Ldc_I4, int.MaxValue); + } + #endregion Prevent UFO Mount from Dismounting in Water + #region Color Blighted Gel private static void ColorBlightedGel(Terraria.GameContent.ItemDropRules.On_CommonCode.orig_ModifyItemDropFromNPC orig, NPC npc, int itemIndex) { diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 9acc1ea443..800f18d622 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -1111,7 +1111,6 @@ namespace CalamityMod.Items break; case ItemID.SquirePlating: player.GetDamage() -= 0.05f; - player.GetDamage() -= 0.05f; break; case ItemID.SquireGreaves: player.GetDamage() -= 0.1f; diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 72dc5d99c3..191b28a627 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -1147,7 +1147,7 @@ namespace CalamityMod.Items if (item.type == ItemID.SquireGreatHelm) EditTooltipByNum(0, (line) => line.Text = "Increases your max number of sentries by 1 and grants +2 HP/s life regen"); if (item.type == ItemID.SquirePlating) - EditTooltipByNum(0, (line) => line.Text = "10% increased minion and melee damage"); + EditTooltipByNum(0, (line) => line.Text = "10% increased minion damage and 15% increased melee damage"); if (item.type == ItemID.SquireGreaves) EditTooltipByNum(0, (line) => line.Text = "5% increased minion damage and melee critical strike chance\n" + "15% increased movement speed"); diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index e4eaf0a5ec..bfd3286fe7 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -323,7 +323,7 @@ namespace CalamityMod.Items { ItemID.BloodLustCluster, Do(AxePower(100), UseTimeExact(13), TileBoostExact(+0)) }, { ItemID.BonePickaxe, Do(PickPower(55), UseTimeExact(6)) }, { ItemID.BorealWoodHammer, Do(HammerPower(25), UseTimeExact(11), TileBoostExact(+0)) }, - { ItemID.ButchersChainsaw, Do(TrueMeleeNoSpeed, AxePower(150), UseTimeExact(3), TileBoostExact(+0), DamageExact(177)) }, + { ItemID.ButchersChainsaw, Do(TrueMeleeNoSpeed, AxePower(150), UseTimeExact(3), TileBoostExact(+0), DamageExact(126)) }, { ItemID.CactusPickaxe, Do(PickPower(34), UseTimeExact(9)) }, { ItemID.CnadyCanePickaxe, Do(PickPower(55), UseTimeExact(9), TileBoostExact(+1)) }, // Candy Cane Pickaxe { ItemID.ChlorophyteChainsaw, Do(TrueMeleeNoSpeed, AxePower(120), UseTimeExact(3), TileBoostExact(+0), DamageExact(112)) }, diff --git a/Items/Weapons/Melee/Avalanche.cs b/Items/Weapons/Melee/Avalanche.cs index d62182a121..43273d55d4 100644 --- a/Items/Weapons/Melee/Avalanche.cs +++ b/Items/Weapons/Melee/Avalanche.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 64; Item.height = 64; - Item.damage = 100; + Item.damage = 75; Item.DamageType = DamageClass.Melee; Item.useAnimation = 35; Item.useTime = 35; @@ -29,39 +29,16 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { - var source = player.GetSource_ItemUse(Item); - int totalProjectiles = 4; - float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); - int bombDamage = player.CalcIntDamage(Item.damage); - float velocity = 4f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); - for (int k = 0; k < totalProjectiles; k++) + if (CalamityUtils.CountProjectiles(type) < 16) { - Vector2 projRotation = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(source, target.Center, projRotation, type, bombDamage, hit.Knockback * 0.5f, Main.myPlayer); - } - } - - public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) - { - var source = player.GetSource_ItemUse(Item); - int totalProjectiles = 4; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - int bombDamage = player.CalcIntDamage(Item.damage); - float velocity = 4f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 projRotation = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(source, target.Center, projRotation, type, bombDamage, 0f, Main.myPlayer); + var source = player.GetSource_ItemUse(Item); + int bombDamage = player.CalcIntDamage(Item.damage); + for (int k = 0; k < 4; k++) + { + // ai0: projectile timer. ai1: target index. ai2: rotation offset based on ice bomb number. + Projectile.NewProjectile(source, target.Center, Vector2.Zero, type, bombDamage, hit.Knockback * 0.5f, Main.myPlayer, 0f, target.whoAmI, k); + } } } diff --git a/Projectiles/Melee/IceBombFriendly.cs b/Projectiles/Melee/IceBombFriendly.cs index 90414812a7..5bd09ba952 100644 --- a/Projectiles/Melee/IceBombFriendly.cs +++ b/Projectiles/Melee/IceBombFriendly.cs @@ -2,6 +2,7 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -13,6 +14,8 @@ namespace CalamityMod.Projectiles.Melee { public new string LocalizationCategory => "Projectiles.Melee"; public override string Texture => "CalamityMod/Projectiles/Boss/IceBomb"; + public ref float Timer => ref Projectile.ai[0]; + public const float FormTime = 60f; public override void SetDefaults() { @@ -22,16 +25,28 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; Projectile.penetrate = 1; - Projectile.timeLeft = 180; + Projectile.timeLeft = 120; Projectile.tileCollide = false; } - public override bool? CanDamage() => Projectile.ai[0] >= 120f; + public override bool? CanDamage() => false; public override void AI() { - Projectile.velocity *= 0.98f; + NPC npc = Main.npc[(int)Projectile.ai[1]]; + // Rotate around the hit enemy + if (!npc.active) + Projectile.Kill(); + else + { + Vector2 centerOffset = new Vector2((npc.height < npc.width ? npc.height : npc.width) * 0.7f, 0f); + // Enforce a minimum offset so that it doesn't look weird on small enemies + centerOffset.X = MathHelper.Max(centerOffset.X, 45f); + Projectile.Center = npc.Center + centerOffset.RotatedBy((MathHelper.Pi / 30f * Timer) + (MathHelper.PiOver2 * Projectile.ai[2])); + } + + // Constantly pulse in size and transparency if (Projectile.localAI[0] == 0f) { Projectile.scale += 0.01f; @@ -53,67 +68,48 @@ namespace CalamityMod.Projectiles.Melee } } - if (Projectile.ai[0] < 120f) + // Once out for long enough, materialize + Timer++; + if (Timer == FormTime) { - Projectile.ai[0] += 1f; - if (Projectile.ai[0] == 120f) + for (int i = 0; i < 8; i++) { - for (int i = 0; i < 8; i++) + Dust icyDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.IceRod, 0f, 0f, 100, default, 2f); + icyDust.velocity *= 3f; + if (Main.rand.NextBool()) { - int icyDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.IceRod, 0f, 0f, 100, default, 2f); - Main.dust[icyDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[icyDust].scale = 0.5f; - Main.dust[icyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } + icyDust.scale = 0.5f; + icyDust.fadeIn = 1f + Main.rand.Next(10) * 0.1f; } - for (int j = 0; j < 14; j++) - { - int icyDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.IceRod, 0f, 0f, 100, default, 3f); - Main.dust[icyDust2].noGravity = true; - Main.dust[icyDust2].velocity *= 5f; - icyDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.IceRod, 0f, 0f, 100, default, 2f); - Main.dust[icyDust2].velocity *= 2f; - } - - Projectile.scale = 1f; - Projectile.ExpandHitboxBy((int)(30f * Projectile.scale)); - SoundEngine.PlaySound(SoundID.Item30, Projectile.Center); } + for (int j = 0; j < 14; j++) + { + Dust icyDust2 = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.IceRod, 0f, 0f, 100, default, 3f); + icyDust2.noGravity = true; + icyDust2.velocity *= 5f; + icyDust2 = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.IceRod, 0f, 0f, 100, default, 2f); + icyDust2.velocity *= 2f; + } + + Projectile.scale = 1f; + Projectile.ExpandHitboxBy((int)(30f * Projectile.scale)); + SoundEngine.PlaySound(SoundID.Item30, Projectile.Center); } } - public override Color? GetAlpha(Color lightColor) - { - return Main.dayTime ? new Color(50, 50, 255, Projectile.alpha) : new Color(255, 255, 255, Projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => Main.dayTime ? new Color(50, 50, 255, Projectile.alpha) : new Color(255, 255, 255, Projectile.alpha); public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item27, Projectile.position); - float spread = 90f * 0.0174f; - double startAngle = Math.Atan2(Projectile.velocity.X, Projectile.velocity.Y) - spread / 2; - double deltaAngle = spread / 8f; - double offsetAngle; - int i; if (Projectile.owner == Main.myPlayer) { - for (i = 0; i < 2; i++) + for (int i = 0; i < 4; i++) { - offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - int projectile1 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), 0f, Projectile.owner, 0f, 0f); - if (projectile1.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[projectile1].DamageType = DamageClass.Melee; - Main.projectile[projectile1].penetrate = 2; - } - int projectile2 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), 0f, Projectile.owner, 0f, 0f); - if (projectile2.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[projectile2].DamageType = DamageClass.Melee; - Main.projectile[projectile2].penetrate = 2; - } + Vector2 shardVelocity = -Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(2.25f, 4.5f); + int iceShard = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, shardVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), 0f, Projectile.owner, 0f, 0f); + if (iceShard.WithinBounds(Main.maxProjectiles)) + Main.projectile[iceShard].DamageType = DamageClass.Melee; } } @@ -121,9 +117,13 @@ namespace CalamityMod.Projectiles.Melee Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.IceRod, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 30); + + public override bool PreDraw(ref Color lightColor) { - target.AddBuff(ModContent.BuffType(), 30); + Texture2D tex = ModContent.Request(Texture).Value; + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, lightColor, Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None); + return false; } } }