diff --git a/Buffs/Summon/DemonshadeSetDevilBuff.cs b/Buffs/Summon/DemonshadeSetDevilBuff.cs index 6aa8bd3748..273319524f 100644 --- a/Buffs/Summon/DemonshadeSetDevilBuff.cs +++ b/Buffs/Summon/DemonshadeSetDevilBuff.cs @@ -1,5 +1,5 @@ using CalamityMod.CalPlayer; -using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Typeless; using Terraria; using Terraria.ModLoader; diff --git a/Buffs/Summon/GladiatorSwords.cs b/Buffs/Summon/GladiatorSwords.cs index 988a10e66e..f4d9bc893d 100644 --- a/Buffs/Summon/GladiatorSwords.cs +++ b/Buffs/Summon/GladiatorSwords.cs @@ -1,5 +1,5 @@ using CalamityMod.CalPlayer; -using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Typeless; using Terraria; using Terraria.ModLoader; diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 1db40eb3bb..1072dacfd9 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -27,6 +27,7 @@ using CalamityMod.NPCs.Providence; using CalamityMod.NPCs.SunkenSea; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.Yharon; +using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; @@ -1039,17 +1040,17 @@ namespace CalamityMod.CalPlayer // Max health reductions if (crimEffigy) - player.statLifeMax2 = (int)((double)player.statLifeMax2 * 0.8); + player.statLifeMax2 = (int)(player.statLifeMax2 * 0.8); if (badgeOfBraveryRare) - player.statLifeMax2 = (int)((double)player.statLifeMax2 * 0.75); + player.statLifeMax2 = (int)(player.statLifeMax2 * 0.75); if (regenator) - player.statLifeMax2 = (int)((double)player.statLifeMax2 * 0.5); + player.statLifeMax2 = (int)(player.statLifeMax2 * 0.5); if (skeletronLore) - player.statLifeMax2 = (int)((double)player.statLifeMax2 * 0.9); + player.statLifeMax2 = (int)(player.statLifeMax2 * 0.9); if (calamitasLore) - player.statLifeMax2 = (int)((double)player.statLifeMax2 * 0.75); + player.statLifeMax2 = (int)(player.statLifeMax2 * 0.75); if (providenceLore) - player.statLifeMax2 = (int)((double)player.statLifeMax2 * 0.8); + player.statLifeMax2 = (int)(player.statLifeMax2 * 0.8); // Extra accessory slots if (extraAccessoryML) @@ -1931,7 +1932,6 @@ namespace CalamityMod.CalPlayer lastProjectileHit = null; - if (CalamityWorld.bossRushActive) { if (!CalamityGlobalNPC.AnyLivingPlayers()) @@ -2713,8 +2713,8 @@ namespace CalamityMod.CalPlayer public static void JungleTeleport(Player player, bool syncData = false) { - int teleportStartX = CalamityWorld.abyssSide ? (int)((double)Main.maxTilesX * 0.65) : (int)((double)Main.maxTilesX * 0.2); - int teleportRangeX = (int)((double)Main.maxTilesX * 0.15); + int teleportStartX = CalamityWorld.abyssSide ? (int)(Main.maxTilesX * 0.65) : (int)(Main.maxTilesX * 0.2); + int teleportRangeX = (int)(Main.maxTilesX * 0.15); int teleportStartY = (int)Main.worldSurface - 75; int teleportRangeY = 50; @@ -3150,7 +3150,7 @@ namespace CalamityMod.CalPlayer ((stressPills || laudanum || draedonsHeart) ? 0.05f : 0f) + ((abyssalDivingSuit && player.IsUnderwater()) ? 0.05f : 0f) + (sirenWaterBuff ? 0.15f : 0f) + - ((frostFlare && player.statLife < (int)((double)player.statLifeMax2 * 0.25)) ? 0.15f : 0f) + + ((frostFlare && player.statLife < (int)(player.statLifeMax2 * 0.25)) ? 0.15f : 0f) + (auricSet ? 0.1f : 0f) + (dragonScales ? 0.1f : 0f) + (cTracers ? 0.1f : 0f) + @@ -3165,7 +3165,7 @@ namespace CalamityMod.CalPlayer float runSpeedMult = 1f + (shadowSpeed ? 0.5f : 0f) + ((abyssalDivingSuit && player.IsUnderwater()) ? 0.05f : 0f) + - ((frostFlare && player.statLife < (int)((double)player.statLifeMax2 * 0.25)) ? 0.15f : 0f) + + ((frostFlare && player.statLife < (int)(player.statLifeMax2 * 0.25)) ? 0.15f : 0f) + (sirenWaterBuff ? 0.15f : 0f) + (auricSet ? 0.1f : 0f) + (dragonScales ? 0.1f : 0f) + @@ -3275,7 +3275,7 @@ namespace CalamityMod.CalPlayer for (int i = 0; i < 50; i++) { - int lumenyl = Projectile.NewProjectile(player.Center.X, player.Center.Y, Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 2f), ModContent.ProjectileType(), 55, 0, player.whoAmI); + int lumenyl = Projectile.NewProjectile(player.Center.X, player.Center.Y, Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 2f), ModContent.ProjectileType(), (int)(55 * player.RogueDamage()), 0, player.whoAmI); Main.projectile[lumenyl].rotation = Main.rand.NextFloat(0, 360); Main.projectile[lumenyl].frame = Main.rand.Next(0, 4); } @@ -3298,7 +3298,7 @@ namespace CalamityMod.CalPlayer } Main.PlaySound(2, (int)Main.player[Main.myPlayer].position.X, (int)Main.player[Main.myPlayer].position.Y, 68); - int eclipseBurst = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 8000, 0, player.whoAmI); + int eclipseBurst = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(7000 * player.RogueDamage()), 0, player.whoAmI); } } #endregion @@ -3570,7 +3570,7 @@ namespace CalamityMod.CalPlayer } if (silvaThrowing) { - if (player.statLife > (int)((double)player.statLifeMax2 * 0.5) && + if (player.statLife > (int)(player.statLifeMax2 * 0.5) && item.Calamity().rogue && item.useTime > 3) return 1.1f; } @@ -3633,13 +3633,14 @@ namespace CalamityMod.CalPlayer if (item.ranged) { - acidRoundMultiplier = (double)(item.useTime) / 20D; + acidRoundMultiplier = item.useTime / 20D; } else { acidRoundMultiplier = 1D; } } + public override void GetWeaponKnockback(Item item, ref float knockback) { if (auricBoost) @@ -3678,7 +3679,7 @@ namespace CalamityMod.CalPlayer { if (item.type == ItemID.SpaceGun && meteorSet) { - mult /= 2; + mult *= 0.5f; } } #endregion @@ -3686,27 +3687,27 @@ namespace CalamityMod.CalPlayer #region Melee Effects public override void MeleeEffects(Item item, Rectangle hitbox) { - if (!item.melee && !item.noMelee && (!item.noUseGraphic && (int) player.meleeEnchant > 0)) + if (!item.melee && !item.noMelee && (!item.noUseGraphic && (int)player.meleeEnchant > 0)) { - if ((int) player.meleeEnchant == 7) + if ((int)player.meleeEnchant == 7) { if (Main.rand.NextBool(20)) { int Type = Main.rand.Next(139, 143); int index = Dust.NewDust(new Vector2(hitbox.X,hitbox.Y), hitbox.Width, hitbox.Height, Type, player.velocity.X, player.velocity.Y, 0, new Color(), 1.2f); - Main.dust[index].velocity.X *= (float) (1.0 + Main.rand.Next(-50, 51) * 0.01); - Main.dust[index].velocity.Y *= (float) (1.0 + Main.rand.Next(-50, 51) * 0.01); + Main.dust[index].velocity.X *= (float)(1.0 + Main.rand.Next(-50, 51) * 0.01); + Main.dust[index].velocity.Y *= (float)(1.0 + Main.rand.Next(-50, 51) * 0.01); Main.dust[index].velocity.X += Main.rand.Next(-50, 51) * 0.05f; Main.dust[index].velocity.Y += Main.rand.Next(-50, 51) * 0.05f; - Main.dust[index].scale *= (float) (1.0 + Main.rand.Next(-30, 31) * 0.01); + Main.dust[index].scale *= (float)(1.0 + Main.rand.Next(-30, 31) * 0.01); } if (Main.rand.NextBool(40)) { int Type = Main.rand.Next(276, 283); int index = Gore.NewGore(new Vector2(hitbox.X, hitbox.Y), player.velocity, Type, 1f); - Main.gore[index].velocity.X *= (float) (1.0 + Main.rand.Next(-50, 51) * 0.01); - Main.gore[index].velocity.Y *= (float) (1.0 + Main.rand.Next(-50, 51) * 0.01); - Main.gore[index].scale *= (float) (1.0 + Main.rand.Next(-20, 21) * 0.01); + Main.gore[index].velocity.X *= (float)(1.0 + Main.rand.Next(-50, 51) * 0.01); + Main.gore[index].velocity.Y *= (float)(1.0 + Main.rand.Next(-50, 51) * 0.01); + Main.gore[index].scale *= (float)(1.0 + Main.rand.Next(-20, 21) * 0.01); Main.gore[index].velocity.X += Main.rand.Next(-50, 51) * 0.05f; Main.gore[index].velocity.Y += Main.rand.Next(-50, 51) * 0.05f; } @@ -3717,59 +3718,59 @@ namespace CalamityMod.CalPlayer { if (fungalSymbiote && player.whoAmI == Main.myPlayer) { - if (player.itemAnimation == (int)((double)player.itemAnimationMax * 0.1) || - player.itemAnimation == (int)((double)player.itemAnimationMax * 0.3) || - player.itemAnimation == (int)((double)player.itemAnimationMax * 0.5) || - player.itemAnimation == (int)((double)player.itemAnimationMax * 0.7) || - player.itemAnimation == (int)((double)player.itemAnimationMax * 0.9)) + if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1) || + player.itemAnimation == (int)(player.itemAnimationMax * 0.3) || + player.itemAnimation == (int)(player.itemAnimationMax * 0.5) || + player.itemAnimation == (int)(player.itemAnimationMax * 0.7) || + player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { float num339 = 0f; float num340 = 0f; float num341 = 0f; float num342 = 0f; - if (player.itemAnimation == (int)((double)player.itemAnimationMax * 0.9)) + if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { num339 = -7f; } - if (player.itemAnimation == (int)((double)player.itemAnimationMax * 0.7)) + if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { num339 = -6f; num340 = 2f; } - if (player.itemAnimation == (int)((double)player.itemAnimationMax * 0.5)) + if (player.itemAnimation == (int)(player.itemAnimationMax * 0.5)) { num339 = -4f; num340 = 4f; } - if (player.itemAnimation == (int)((double)player.itemAnimationMax * 0.3)) + if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3)) { num339 = -2f; num340 = 6f; } - if (player.itemAnimation == (int)((double)player.itemAnimationMax * 0.1)) + if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1)) { num340 = 7f; } - if (player.itemAnimation == (int)((double)player.itemAnimationMax * 0.7)) + if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { num342 = 26f; } - if (player.itemAnimation == (int)((double)player.itemAnimationMax * 0.3)) + if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3)) { num342 -= 4f; num341 -= 20f; } - if (player.itemAnimation == (int)((double)player.itemAnimationMax * 0.1)) + if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1)) { num341 += 6f; } if (player.direction == -1) { - if (player.itemAnimation == (int)((double)player.itemAnimationMax * 0.9)) + if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { num342 -= 8f; } - if (player.itemAnimation == (int)((double)player.itemAnimationMax * 0.7)) + if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { num342 -= 6f; } @@ -4841,7 +4842,7 @@ namespace CalamityMod.CalPlayer } } } - damage = (int)((double)damage * damageMult); + damage = (int)(damage * damageMult); if (oldDie) { @@ -4871,15 +4872,15 @@ namespace CalamityMod.CalPlayer #endregion if (yharonLore) - damage = (int)((double)damage * 0.75); + damage = (int)(damage * 0.75); if ((target.damage > 5 || target.boss) && player.whoAmI == Main.myPlayer && !target.SpawnedFromStatue) { if (isTrueMelee && soaring) { - double useTimeMultiplier = 0.85 + ((double)(item.useTime * item.useAnimation) / 3600D); //28 * 28 = 784 is average so that equals 784 / 3600 = 0.217777 + 1 = 21.7% boost - double wingTimeFraction = (double)player.wingTimeMax / 20D; - double meleeStatMultiplier = (double)(player.meleeDamage * (float)((double)player.meleeCrit / 10D)); + double useTimeMultiplier = 0.85 + (item.useTime * item.useAnimation / 3600D); //28 * 28 = 784 is average so that equals 784 / 3600 = 0.217777 + 1 = 21.7% boost + double wingTimeFraction = player.wingTimeMax / 20D; + double meleeStatMultiplier = (double)(player.meleeDamage * (float)(player.meleeCrit / 10D)); if (player.wingTime < player.wingTimeMax) player.wingTime += (int)(useTimeMultiplier * (wingTimeFraction + meleeStatMultiplier)); @@ -4893,7 +4894,7 @@ namespace CalamityMod.CalPlayer { if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 3) { - Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)((double)damage * 0.15), 2f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(damage * 0.15), 2f, player.whoAmI, 0f, 0f); } } if (unstablePrism && crit) @@ -4907,7 +4908,7 @@ namespace CalamityMod.CalPlayer } value15.Normalize(); value15 *= (float)Main.rand.Next(30, 61) * 0.1f; - Projectile.NewProjectile(target.Center.X, target.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)((double)damage * 0.15), 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(target.Center.X, target.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(damage * 0.15), 0f, player.whoAmI, 0f, 0f); } } } @@ -4987,7 +4988,7 @@ namespace CalamityMod.CalPlayer { if (item.melee) { - int stressGain = (int)((double)damage * 0.1); + int stressGain = (int)(damage * 0.1); int stressMaxGain = 10; if (stressGain < 1) { @@ -5018,16 +5019,16 @@ namespace CalamityMod.CalPlayer return; bool isTrueMelee = proj.Calamity().trueMelee; - bool isSummon = proj.minion || proj.sentry || CalamityMod.projectileMinionList.Contains(proj.type); + bool isSummon = proj.minion || proj.sentry || CalamityMod.projectileMinionList.Contains(proj.type); bool hasClassType = proj.melee || proj.ranged || proj.magic || isSummon || proj.Calamity().rogue; Item heldItem = player.inventory[player.selectedItem]; if (isTrueMelee && soaring) { - double useTimeMultiplier = 0.85 + ((double)(heldItem.useTime * heldItem.useAnimation) / 3600D); //28 * 28 = 784 is average so that equals 784 / 3600 = 0.217777 + 1 = 21.7% boost - double wingTimeFraction = (double)player.wingTimeMax / 20D; - double meleeStatMultiplier = (double)(player.meleeDamage * (float)((double)player.meleeCrit / 10D)); + double useTimeMultiplier = 0.85 + (heldItem.useTime * heldItem.useAnimation / 3600D); //28 * 28 = 784 is average so that equals 784 / 3600 = 0.217777 + 1 = 21.7% boost + double wingTimeFraction = player.wingTimeMax / 20D; + double meleeStatMultiplier = (double)(player.meleeDamage * (float)(player.meleeCrit / 10D)); if (player.wingTime < player.wingTimeMax) player.wingTime += (int)(useTimeMultiplier * (wingTimeFraction + meleeStatMultiplier)); @@ -5209,7 +5210,7 @@ namespace CalamityMod.CalPlayer #region AdditiveBoosts if (proj.type == ModContent.ProjectileType()) { - int defenseAdd = (int)((double)target.defense * 0.05 * ((double)proj.damage / 50D) * acidRoundMultiplier); //100 defense * 0.05 = 5 + int defenseAdd = (int)(target.defense * 0.05 * (proj.damage / 50D) * acidRoundMultiplier); //100 defense * 0.05 = 5 damage += defenseAdd; } if (uberBees && (proj.type == ProjectileID.GiantBee || proj.type == ProjectileID.Bee || proj.type == ProjectileID.Wasp || proj.type == ModContent.ProjectileType())) @@ -5325,7 +5326,7 @@ namespace CalamityMod.CalPlayer } value15.Normalize(); value15 *= (float)Main.rand.Next(30, 61) * 0.1f; - Projectile.NewProjectile(proj.oldPosition.X + (float)(proj.width / 2), proj.oldPosition.Y + (float)(proj.height / 2), value15.X, value15.Y, ModContent.ProjectileType(), (int)((double)damage * 0.15), 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(proj.oldPosition.X + (float)(proj.width / 2), proj.oldPosition.Y + (float)(proj.height / 2), value15.X, value15.Y, ModContent.ProjectileType(), (int)(damage * 0.15), 0f, player.whoAmI, 0f, 0f); } } if (electricianGlove && proj.Calamity().stealthStrike && proj.Calamity().rogue) @@ -5339,7 +5340,7 @@ namespace CalamityMod.CalPlayer } value15.Normalize(); value15 *= (float)Main.rand.Next(30, 61) * 0.1f; - int num17 = Projectile.NewProjectile(proj.oldPosition.X + (float)(proj.width / 2), proj.oldPosition.Y + (float)(proj.height / 2), value15.X, value15.Y, ModContent.ProjectileType(), (int)((double)damage * 0.1), 0f, player.whoAmI, 0f, 0f); + int num17 = Projectile.NewProjectile(proj.oldPosition.X + (float)(proj.width / 2), proj.oldPosition.Y + (float)(proj.height / 2), value15.X, value15.Y, ModContent.ProjectileType(), (int)(damage * 0.1), 0f, player.whoAmI, 0f, 0f); Main.projectile[num17].Calamity().forceRogue = true; Main.projectile[num17].localNPCHitCooldown = -1; } @@ -5390,7 +5391,7 @@ namespace CalamityMod.CalPlayer value15.Normalize(); value15 *= (float)Main.rand.Next(70, 101) * 0.1f; int FUCKYOU = Projectile.NewProjectile(target.position.X + (float)(target.width / 2), target.position.Y + (float)(target.height / 2), - value15.X, value15.Y, ProjectileID.Leaf, (int)((double)damage * 0.25), 0f, player.whoAmI, 0f, 0f); + value15.X, value15.Y, ProjectileID.Leaf, (int)(damage * 0.25), 0f, player.whoAmI, 0f, 0f); Main.projectile[FUCKYOU].magic = false; Main.projectile[FUCKYOU].netUpdate = true; } @@ -5438,7 +5439,7 @@ namespace CalamityMod.CalPlayer } if (umbraphileSet && proj.Calamity().rogue && (Main.rand.NextBool(4) || proj.Calamity().stealthStrike)) { - int newDamage = (int)((double)proj.damage * 0.25); + int newDamage = (int)(proj.damage * 0.25); if (newDamage > 50) { newDamage = 50; @@ -5606,7 +5607,7 @@ namespace CalamityMod.CalPlayer if (triumph) { double HPMultiplier = 0.15 * (1.0 - ((double)npc.life / (double)npc.lifeMax)); - int damageReduction = (int)((double)damage * HPMultiplier); + int damageReduction = (int)(damage * HPMultiplier); damage -= damageReduction; } if (aSparkRare) @@ -5631,7 +5632,7 @@ namespace CalamityMod.CalPlayer } if (silvaMelee && silvaCountdown <= 0 && hasSilvaEffect) { - damage = (int)((double)damage * 0.8); + damage = (int)(damage * 0.8); } if (aBulwarkRare) { @@ -5695,7 +5696,7 @@ namespace CalamityMod.CalPlayer if (projRefRare) { if (proj.type == projTypeJustHitBy) - damage = (int)((double)damage * 0.85); + damage = (int)(damage * 0.85); } if (aSparkRare) { @@ -5705,17 +5706,17 @@ namespace CalamityMod.CalPlayer } if (proj.type == ProjectileID.Nail) { - damage = (int)((double)damage * 0.75); + damage = (int)(damage * 0.75); } if (beeResist) { if (CalamityMod.beeProjectileList.Contains(proj.type)) - damage = (int)((double)damage * 0.75); + damage = (int)(damage * 0.75); } if (Main.hardMode && Main.expertMode && !CalamityWorld.spawnedHardBoss && proj.active && !proj.friendly && proj.hostile && damage > 0) { if (CalamityMod.hardModeNerfList.Contains(proj.type)) - damage = (int)((double)damage * 0.75); + damage = (int)(damage * 0.75); } if (CalamityWorld.revenge) { @@ -5750,14 +5751,17 @@ namespace CalamityMod.CalPlayer // Reduce damage from vanilla traps // 350 in normal, 450 in expert if (proj.type == ProjectileID.Explosives) - damage = (int)((double)damage * (Main.expertMode ? 0.225 : 0.35)); + damage = (int)(damage * (Main.expertMode ? 0.225 : 0.35)); if (Main.expertMode) { // 140 in normal, 182 in expert if (proj.type == ProjectileID.Boulder) - damage = (int)((double)damage * 0.65); + damage = (int)(damage * 0.65); } + if (proj.type == ModContent.ProjectileType()) + damage = 0; + if (player.whoAmI == Main.myPlayer && gainRageCooldown <= 0) { if (CalamityWorld.revenge && CalamityMod.CalamityConfig.AdrenalineAndRage && !CalamityMod.trapProjectileList.Contains(proj.type)) @@ -6038,7 +6042,7 @@ namespace CalamityMod.CalPlayer player.head = mod.GetEquipSlot("ProviHead", EquipType.Head); player.wings = mod.GetEquipSlot("ProviWings", EquipType.Wings); - bool enrage = !profanedCrystalForce && profanedCrystalBuffs && player.statLife <= (int)((double)player.statLifeMax2 * 0.5); + bool enrage = !profanedCrystalForce && profanedCrystalBuffs && player.statLife <= (int)(player.statLifeMax2 * 0.5); if (profanedCrystalWingCounter.Value == 0) { @@ -6110,7 +6114,7 @@ namespace CalamityMod.CalPlayer player.gravControl = false; player.gravControl2 = false; player.jumpSpeedBoost = 0f; - player.wingTimeMax = (int)((double)player.wingTimeMax * 0.5); + player.wingTimeMax = (int)(player.wingTimeMax * 0.5); player.balloon = -1; weakPetrification = true; } @@ -6206,13 +6210,13 @@ namespace CalamityMod.CalPlayer damageMult += 0.2; } - damage = (int)((double)damage * damageMult); + damage = (int)(damage * damageMult); #endregion if (CalamityWorld.revenge) { customDamage = true; - double newDamage = (double)damage - ((double)player.statDefense * 0.75); + double newDamage = (double)damage - (player.statDefense * 0.75); double newDamageLimit = 5.0 + (Main.hardMode ? 5.0 : 0.0) + (NPC.downedPlantBoss ? 5.0 : 0.0) + (NPC.downedMoonlord ? 5.0 : 0.0); //5, 10, 15, 20 if (newDamage < newDamageLimit) { @@ -6224,11 +6228,11 @@ namespace CalamityMod.CalPlayer #region MultiplicativeReductions if (trinketOfChiBuff) { - damage = (int)((double)damage * 0.85); + damage = (int)(damage * 0.85); } if (purpleCandle) { - damage = (int)((double)damage - ((double)player.statDefense * 0.05)); + damage = (int)((double)damage - (player.statDefense * 0.05)); } // Fearmonger set provides 15% multiplicative DR that ignores caps during the Holiday Moons. // To prevent abuse, this effect does not work if there are any bosses alive. @@ -6238,36 +6242,36 @@ namespace CalamityMod.CalPlayer } if (abyssalDivingSuitPlates) { - damage = (int)((double)damage * 0.85); + damage = (int)(damage * 0.85); } if (sirenIce) { - damage = (int)((double)damage * 0.85); + damage = (int)(damage * 0.85); } if (encased) { - damage = (int)((double)damage * 0.7); + damage = (int)(damage * 0.7); } if (theBee && player.statLife >= player.statLifeMax2 && theBeeCooldown <= 0) { - damage = (int)((double)damage * 0.5); + damage = (int)(damage * 0.5); theBeeCooldown = 600; } if (CalamityWorld.revenge) { if (!CalamityWorld.downedBossAny) - damage = (int)((double)damage * 0.8); + damage = (int)(damage * 0.8); if (CalamityMod.CalamityConfig.AdrenalineAndRage) { if (adrenaline == adrenalineMax && !adrenalineMode) - damage = (int)((double)damage * 0.5); + damage = (int)(damage * 0.5); } } if (player.mount.Active && (player.mount.Type == ModContent.MountType() || player.mount.Type == ModContent.MountType()) && Math.Abs(player.velocity.X) > player.mount.RunSpeed / 2f) { - damage = (int)((double)damage * 0.9); + damage = (int)(damage * 0.9); } #endregion @@ -6468,11 +6472,12 @@ namespace CalamityMod.CalPlayer if (arg_67A_0 < num10) { float num11 = (float)Main.rand.Next(90 + (int)damage / 3, 300 + (int)damage / 2); - Main.npc[m].AddBuff(31, (int)num11, false); + Main.npc[m].AddBuff(BuffID.Confused, (int)num11, false); } } } - Projectile.NewProjectile(player.Center.X + (float)Main.rand.Next(-40, 40), player.Center.Y - (float)Main.rand.Next(20, 60), player.velocity.X * 0.3f, player.velocity.Y * 0.3f, 565, 0, 0f, player.whoAmI, 0f, 0f); + //spawn the harmless brain images that are actually projectiles + Projectile.NewProjectile(player.Center.X + (float)Main.rand.Next(-40, 40), player.Center.Y - (float)Main.rand.Next(20, 60), player.velocity.X * 0.3f, player.velocity.Y * 0.3f, ProjectileID.BrainOfConfusion, 0, 0f, player.whoAmI, 0f, 0f); } if (polarisBoost) { @@ -6566,7 +6571,7 @@ namespace CalamityMod.CalPlayer num16 = (float)num15 / num16; num13 *= num16; num14 *= num16; - int num17 = Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType(), 20, 1f, player.whoAmI, 0f, 0f); + int num17 = Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType(), (int)(20 * player.AverageDamage()), 1f, player.whoAmI, 0f, 0f); } } } @@ -6575,7 +6580,7 @@ namespace CalamityMod.CalPlayer if (aBulwarkRare) { Main.PlaySound(2, (int)player.position.X, (int)player.position.Y, 74); - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 25, 5f, player.whoAmI, 0f, 1f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(25 * player.AverageDamage()), 5f, player.whoAmI, 0f, 1f); } int starAmt = aBulwarkRare ? 12 : 5; for (int n = 0; n < starAmt; n++) @@ -6591,7 +6596,7 @@ namespace CalamityMod.CalPlayer num16 = (float)num15 / num16; num13 *= num16; num14 *= num16; - int num17 = Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType(), 320, 5f, player.whoAmI, 0f, 0f); + int num17 = Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType(), (int)(320 * player.AverageDamage()), 5f, player.whoAmI, 0f, 0f); } } if (dAmulet) @@ -6609,7 +6614,7 @@ namespace CalamityMod.CalPlayer num16 = (float)num15 / num16; num13 *= num16; num14 *= num16; - int star = Projectile.NewProjectile(x, y, num13, num14, 92, 130, 4f, player.whoAmI, 0f, 0f); + int star = Projectile.NewProjectile(x, y, num13, num14, ProjectileID.HallowStar, (int)(130 * player.AverageDamage()), 4f, player.whoAmI, 0f, 0f); Main.projectile[star].usesLocalNPCImmunity = true; Main.projectile[star].localNPCHitCooldown = 5; Main.projectile[star].ranged = false; @@ -6644,7 +6649,7 @@ namespace CalamityMod.CalPlayer num16 = (float)num15 / num16; num13 *= num16; num14 *= num16; - int star = Projectile.NewProjectile(x, y, num13, num14, 92, 130, 4f, player.whoAmI, 0f, 0f); + int star = Projectile.NewProjectile(x, y, num13, num14, ProjectileID.HallowStar, (int)(150 * player.AverageDamage()), 4f, player.whoAmI, 0f, 0f); Main.projectile[star].usesLocalNPCImmunity = true; Main.projectile[star].localNPCHitCooldown = 5; Main.projectile[star].ranged = false; @@ -6674,7 +6679,7 @@ namespace CalamityMod.CalPlayer double deltaAngle = spread / 8f; double offsetAngle; int i; - int fDamage = 56; + int fDamage = (int)(56 * player.AverageDamage()); if (player.whoAmI == Main.myPlayer) { for (i = 0; i < 4; i++) @@ -6708,10 +6713,12 @@ namespace CalamityMod.CalPlayer for (i = 0; i < 4; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - int spark1 = Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), sDamage, 1.25f, player.whoAmI, 0f, 0f); - int spark2 = Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), sDamage, 1.25f, player.whoAmI, 0f, 0f); + int spark1 = Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)(sDamage * player.AverageDamage()), 1.25f, player.whoAmI, 0f, 0f); + int spark2 = Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)(sDamage * player.AverageDamage()), 1.25f, player.whoAmI, 0f, 0f); Main.projectile[spark1].timeLeft = 120; Main.projectile[spark2].timeLeft = 120; + Main.projectile[spark1].melee = false; + Main.projectile[spark2].melee = false; } } } @@ -6739,7 +6746,7 @@ namespace CalamityMod.CalPlayer Dust.NewDust(player.Center, 1, 1, 244, BCDSpeed.X, BCDSpeed.Y, 0, default, 1.1f); } Main.PlaySound(SoundID.Item14, player.Center); - int blazingSun = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), 1690, 0f, player.whoAmI, 0f, 0f); + int blazingSun = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(1690 * player.AverageDamage()), 0f, player.whoAmI, 0f, 0f); Main.projectile[blazingSun].Center = player.Center; int blazingSun2 = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); Main.projectile[blazingSun2].Center = player.Center; @@ -6750,7 +6757,7 @@ namespace CalamityMod.CalPlayer if (damage > 0) { Main.PlaySound(2, (int)player.position.X, (int)player.position.Y, 74); - int eDamage = 100; + int eDamage = (int)(100 * player.AverageDamage()); if (player.whoAmI == Main.myPlayer) { Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), eDamage, 1f, player.whoAmI, 0f, 0f); @@ -6767,7 +6774,7 @@ namespace CalamityMod.CalPlayer double deltaAngle = spread / 8f; double offsetAngle; int i; - int sDamage = 27; + int sDamage = (int)(27 * player.RangedDamage()); //daedalus ranged helm if (player.whoAmI == Main.myPlayer) { for (i = 0; i < 8; i++) @@ -6793,7 +6800,7 @@ namespace CalamityMod.CalPlayer double deltaAngle = spread / 8f; double offsetAngle; int i; - int rDamage = 58; + int rDamage = (int)(58 * player.RogueDamage()); //Reaver rogue helm if (player.whoAmI == Main.myPlayer) { for (i = 0; i < 4; i++) @@ -6811,7 +6818,7 @@ namespace CalamityMod.CalPlayer } } } - else if (godSlayerDamage) + else if (godSlayerDamage) //god slayer melee helm { if (damage > 80) { @@ -6826,8 +6833,8 @@ namespace CalamityMod.CalPlayer for (i = 0; i < 4; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), 900, 5f, player.whoAmI, 0f, 0f); - Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), 900, 5f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)(900 * player.MeleeDamage()), 5f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)(900 * player.MeleeDamage()), 5f, player.whoAmI, 0f, 0f); } } } @@ -6839,7 +6846,7 @@ namespace CalamityMod.CalPlayer Main.PlaySound(2, (int)player.position.X, (int)player.position.Y, 74); if (player.whoAmI == Main.myPlayer) { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), auricSet ? 2400 : 1200, 1f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)((auricSet ? 2400 : 1200) * player.MagicDamage()), 1f, player.whoAmI, 0f, 0f); } } } @@ -6860,10 +6867,11 @@ namespace CalamityMod.CalPlayer num18 = (float)num17 / num18; num15 *= num18; num16 *= num18; - int num19 = Projectile.NewProjectile(x, y, num15, num16, ProjectileID.ShadowBeamFriendly, 3000, 7f, player.whoAmI, 0f, 0f); + int num19 = Projectile.NewProjectile(x, y, num15, num16, ProjectileID.ShadowBeamFriendly, (int)(3000 * player.AverageDamage()), 7f, player.whoAmI, 0f, 0f); Main.projectile[num19].ai[1] = player.position.Y; Main.projectile[num19].usesLocalNPCImmunity = true; Main.projectile[num19].localNPCHitCooldown = 10; + Main.projectile[num19].magic = false; } for (int l = 0; l < 5; l++) { @@ -6878,10 +6886,11 @@ namespace CalamityMod.CalPlayer num18 = (float)num17 / num18; num15 *= num18; num16 *= num18; - int num19 = Projectile.NewProjectile(x, y, num15, num16, ProjectileID.DemonScythe, 5000, 7f, player.whoAmI, 0f, 0f); + int num19 = Projectile.NewProjectile(x, y, num15, num16, ProjectileID.DemonScythe, (int)(5000 * player.AverageDamage()), 7f, player.whoAmI, 0f, 0f); Main.projectile[num19].ai[1] = player.position.Y; Main.projectile[num19].usesLocalNPCImmunity = true; Main.projectile[num19].localNPCHitCooldown = 10; + Main.projectile[num19].magic = false; } } } @@ -6999,7 +7008,7 @@ namespace CalamityMod.CalPlayer player.respawnTimer = 600; if (Main.expertMode) { - player.respawnTimer = (int)((double)player.respawnTimer * 1.5); + player.respawnTimer = (int)(player.respawnTimer * 1.5); } player.immuneAlpha = 0; player.palladiumRegen = false; @@ -7085,7 +7094,7 @@ namespace CalamityMod.CalPlayer Rectangle rect = nPC.getRect(); if (rectangle.Intersects(rect) && (nPC.noTileCollide || player.CanHit(nPC))) { - float num = 50f * player.MeleeDamage(); + float num = 50f * player.AverageDamage(); float num2 = 3f; bool crit = false; if (player.kbGlove) @@ -7139,7 +7148,7 @@ namespace CalamityMod.CalPlayer Rectangle rect = nPC.getRect(); if (rectangle.Intersects(rect) && (nPC.noTileCollide || player.CanHit(nPC))) { - float num = 1500f * player.MeleeDamage(); + float num = 1500f * player.AverageDamage(); float num2 = 15f; bool crit = false; if (player.kbGlove) @@ -7166,9 +7175,8 @@ namespace CalamityMod.CalPlayer if (player.whoAmI == Main.myPlayer) { player.ApplyDamageToNPC(nPC, (int)num, num2, direction, crit); - int num6 = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 1000, 20f, Main.myPlayer, 0f, 0f); - Main.projectile[num6].Kill(); - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 780, 5f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(1000 * player.AverageDamage()), 20f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(780 * player.AverageDamage()), 5f, Main.myPlayer, 0f, 0f); } if (nPC.immune[player.whoAmI] < 6) nPC.immune[player.whoAmI] = 6; @@ -7196,7 +7204,7 @@ namespace CalamityMod.CalPlayer Rectangle rect = nPC.getRect(); if (rectangle.Intersects(rect) && (nPC.noTileCollide || player.CanHit(nPC))) { - float num = 500f * player.MeleeDamage(); + float num = 500f * player.AverageDamage(); float num2 = 12f; bool crit = false; if (player.kbGlove) @@ -7223,9 +7231,8 @@ namespace CalamityMod.CalPlayer if (player.whoAmI == Main.myPlayer) { player.ApplyDamageToNPC(nPC, (int)num, num2, direction, crit); - int num6 = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 500, 15f, Main.myPlayer, 0f, 0f); - Main.projectile[num6].Kill(); - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 380, 5f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(500 * player.AverageDamage()), 15f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(380 * player.AverageDamage()), 5f, Main.myPlayer, 0f, 0f); } if (nPC.immune[player.whoAmI] < 6) nPC.immune[player.whoAmI] = 6; @@ -7252,7 +7259,7 @@ namespace CalamityMod.CalPlayer Rectangle rect = nPC.getRect(); if (rectangle.Intersects(rect) && (nPC.noTileCollide || player.CanHit(nPC))) { - float num = 100f * player.MeleeDamage(); + float num = 100f * player.AverageDamage(); float num2 = 9f; bool crit = false; if (player.kbGlove) @@ -7279,8 +7286,7 @@ namespace CalamityMod.CalPlayer if (player.whoAmI == Main.myPlayer) { player.ApplyDamageToNPC(nPC, (int)num, num2, direction, crit); - int num6 = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 100, 15f, Main.myPlayer, 0f, 0f); - Main.projectile[num6].Kill(); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(100 * player.AverageDamage()), 15f, Main.myPlayer, 0f, 0f); } if (nPC.immune[player.whoAmI] < 6) nPC.immune[player.whoAmI] = 6; @@ -7455,7 +7461,7 @@ namespace CalamityMod.CalPlayer num7 = 14f; //14 if (statisTimer % 5 == 0) { - int scythe = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(500 * player.allDamage), 5f, player.whoAmI, 1f); + int scythe = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(500 * player.AverageDamage()), 5f, player.whoAmI, 1f); Main.projectile[scythe].Calamity().rogue = false; Main.projectile[scythe].usesIDStaticNPCImmunity = true; Main.projectile[scythe].idStaticNPCHitCooldown = 10 * Main.projectile[scythe].extraUpdates; @@ -10461,7 +10467,7 @@ namespace CalamityMod.CalPlayer bool isInvalidTransFrame = !IsValidTransitionFrame(currentType, newType, key, value); //to make the transition between walk and idle frames less jarring and smoother AnimationType type = isInvalidTransFrame ? newType : currentType; - int frameCount = type == AnimationType.Walk || (!profanedCrystalForce && player.statLife <= (int)((double)player.statLifeMax2 * 0.5)) ? 7 : 10; + int frameCount = type == AnimationType.Walk || (!profanedCrystalForce && player.statLife <= (int)(player.statLifeMax2 * 0.5)) ? 7 : 10; int lowerRange = type == AnimationType.Idle ? 0 : type == AnimationType.Jump ? 8 : 9; int upperRange = type == AnimationType.Idle ? 7 : type == AnimationType.Jump ? 8 : 22; if (value <= 0 || !isInvalidTransFrame) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 4105301b5d..4156e338a1 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -785,11 +785,7 @@ namespace CalamityMod.CalPlayer { if (!tentaclesPresent[i]) { - float modifier = player.meleeDamage + player.magicDamage + player.rangedDamage + - modPlayer.throwingDamage + player.minionDamage + ((player.allDamage - 1f) * 5f); - - modifier /= 5f; - int damage = (int)(666 * modifier); + int damage = (int)(666 * player.AverageDamage()); Vector2 vel = new Vector2(Main.rand.Next(-13, 14), Main.rand.Next(-13, 14)) * 0.25f; Projectile.NewProjectile(player.Center, vel, ModContent.ProjectileType(), damage, 8f, Main.myPlayer, Main.rand.Next(120), i); } @@ -1294,7 +1290,7 @@ namespace CalamityMod.CalPlayer } if (modPlayer.eaterOfWorldsLore) { - int damage = 20; + int damage = (int)(15 * player.AverageDamage()); float knockBack = 1f; if (Main.rand.NextBool(15)) { @@ -1661,7 +1657,7 @@ namespace CalamityMod.CalPlayer Vector2 cloudVelocity = new Vector2(Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1)); cloudVelocity.Normalize(); cloudVelocity *= Main.rand.NextFloat(0f, 1f); - int projectile = Projectile.NewProjectile(player.Center, cloudVelocity, ModContent.ProjectileType(), 20, 0, player.whoAmI, 0, 0); + int projectile = Projectile.NewProjectile(player.Center, cloudVelocity, ModContent.ProjectileType(), (int)(20 * player.RogueDamage()), 0, player.whoAmI, 0, 0); Main.projectile[projectile].timeLeft = Main.rand.Next(180, 240); } @@ -3126,7 +3122,7 @@ namespace CalamityMod.CalPlayer if (modPlayer.navyRodAuraTimer == 0 && player.whoAmI == Main.myPlayer) { const int BaseDamage = 10; - int damage = (int)(BaseDamage * player.allDamage); + int damage = (int)(BaseDamage * player.AverageDamage()); float range = 200f; for (int i = 0; i < Main.maxNPCs; ++i) @@ -3169,7 +3165,7 @@ namespace CalamityMod.CalPlayer if (player.whoAmI == Main.myPlayer) { const int BaseDamage = 50; - int damage = (int)(BaseDamage * player.allDamage); + int damage = (int)(BaseDamage * player.AverageDamage()); float range = 300f; for (int i = 0; i < Main.maxNPCs; ++i) @@ -3363,7 +3359,7 @@ namespace CalamityMod.CalPlayer if (player.whoAmI == Main.myPlayer) { if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 15, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(10 * player.AverageDamage()), 0f, Main.myPlayer, 0f, 0f); } } else if (player.ownedProjectileCounts[ModContent.ProjectileType()] != 0) diff --git a/CalamityMod.cs b/CalamityMod.cs index d08a711471..f1b0645611 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -1737,6 +1737,7 @@ namespace CalamityMod ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), + ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), diff --git a/Items/Accessories/AmalgamatedBrain.cs b/Items/Accessories/AmalgamatedBrain.cs index a223c0cc0a..4c291ba199 100644 --- a/Items/Accessories/AmalgamatedBrain.cs +++ b/Items/Accessories/AmalgamatedBrain.cs @@ -51,11 +51,12 @@ namespace CalamityMod.Items.Accessories num18 = (float)num17 / num18; num15 *= num18; num16 *= num18; - int num19 = Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), 60, 2f, player.whoAmI, 0f, 0f); + int num19 = Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), (int)(60 * player.AverageDamage()), 2f, player.whoAmI, 0f, 0f); Main.projectile[num19].ai[1] = player.position.Y; Main.projectile[num19].tileCollide = false; Main.projectile[num19].usesLocalNPCImmunity = true; Main.projectile[num19].localNPCHitCooldown = 10; + Main.projectile[num19].magic = false; } } } diff --git a/Items/Accessories/AmidiasPendant.cs b/Items/Accessories/AmidiasPendant.cs index ba7b7e3772..804543be9c 100644 --- a/Items/Accessories/AmidiasPendant.cs +++ b/Items/Accessories/AmidiasPendant.cs @@ -1,4 +1,4 @@ -using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Amidias' Pendant"); - Tooltip.SetDefault("Periodically rains down prism shards"); + Tooltip.SetDefault("Periodically rains down prism shards that can briefly stun enemies"); } public override void SetDefaults() @@ -28,14 +28,14 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - if (ShardCountdown == 0) + if (ShardCountdown <= 0) { - ShardCountdown = 120; + ShardCountdown = 140; } if (ShardCountdown > 0) { - ShardCountdown--; - if (ShardCountdown == 0) + ShardCountdown -= Main.rand.Next(1,4); + if (ShardCountdown <= 0) { if (player.whoAmI == Main.myPlayer) { @@ -69,9 +69,7 @@ namespace CalamityMod.Items.Accessories damage = 30; break; } - int projectile = Projectile.NewProjectile(spawn.X, spawn.Y, velocity.X / 3, velocity.Y / 2, type, damage, 5f, Main.myPlayer, 0f, 0f); - Main.projectile[projectile].tileCollide = false; - Main.projectile[projectile].timeLeft = 220; + Projectile.NewProjectile(spawn.X, spawn.Y, velocity.X / 3, velocity.Y / 2, type, (int)(damage * player.AverageDamage()), 5f, Main.myPlayer, 0f, 0f); } } } diff --git a/Items/Accessories/BloomStone.cs b/Items/Accessories/BloomStone.cs index b30a539f2e..c21b6768b3 100644 --- a/Items/Accessories/BloomStone.cs +++ b/Items/Accessories/BloomStone.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Accessories int num = 186; float num2 = 150f; bool flag = bloomCounter % 60 == 0; - int num3 = 10; + int num3 = (int)(10 * player.AverageDamage()); int random = Main.rand.Next(10); if (player.whoAmI == Main.myPlayer) { diff --git a/Items/Accessories/CalamityRing.cs b/Items/Accessories/CalamityRing.cs index 0649ca75ff..d3432a6760 100644 --- a/Items/Accessories/CalamityRing.cs +++ b/Items/Accessories/CalamityRing.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Items.Accessories num18 = (float)num17 / num18; num15 *= num18; num16 *= num18; - int num19 = Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), 30, 5f, player.whoAmI, 0f, 0f); + int num19 = Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), (int)(30 * player.AverageDamage()), 5f, player.whoAmI, 0f, 0f); Main.projectile[num19].ai[1] = player.position.Y; } } diff --git a/Items/Accessories/CorrosiveSpine.cs b/Items/Accessories/CorrosiveSpine.cs index 28c5ce744f..f3f4664189 100644 --- a/Items/Accessories/CorrosiveSpine.cs +++ b/Items/Accessories/CorrosiveSpine.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Items.Accessories { float speed = Main.rand.NextFloat(3f, 11f); Projectile.NewProjectile(player.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * speed, - type, 100, 0f, player.whoAmI); + type, (int)(100 * player.RogueDamage()), 0f, player.whoAmI); } } } diff --git a/Items/Accessories/Gehenna.cs b/Items/Accessories/Gehenna.cs index 9e95f9c1dc..6d1362905e 100644 --- a/Items/Accessories/Gehenna.cs +++ b/Items/Accessories/Gehenna.cs @@ -1,4 +1,4 @@ -using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -53,9 +53,7 @@ namespace CalamityMod.Items.Accessories spawn.X = spawn.X + i * 30 - (FireProjectiles * 15); Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-FireAngleSpread / 2 + (FireAngleSpread * i / (float)FireProjectiles))); velocity.X = velocity.X + 3 * Main.rand.NextFloat() - 1.5f; - int projectile = Projectile.NewProjectile(spawn.X, spawn.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), 54, 5f, Main.myPlayer, 0f, 0f); - Main.projectile[projectile].tileCollide = false; - Main.projectile[projectile].timeLeft = 50; + Projectile.NewProjectile(spawn.X, spawn.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), (int)(54 * player.AverageDamage()), 5f, Main.myPlayer, 0f, 0f); } } } diff --git a/Items/Accessories/GladiatorsLocket.cs b/Items/Accessories/GladiatorsLocket.cs index 726b2e02f1..92d8991cd4 100644 --- a/Items/Accessories/GladiatorsLocket.cs +++ b/Items/Accessories/GladiatorsLocket.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; -using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Typeless; +using CalamityMod.World; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -43,10 +44,13 @@ namespace CalamityMod.Items.Accessories { player.AddBuff(ModContent.BuffType(), 3600, true); } + int damage = NPC.downedPlantBoss ? 100 : Main.hardMode ? 50 : 20; + float damageMult = CalamityWorld.downedDoG ? 3f : NPC.downedMoonlord ? 2f : 1f; + int swordDmg = (int)(damage * damageMult * player.AverageDamage()); if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(20f * (player.allDamage + player.minionDamage - 1f)), 6f, Main.myPlayer, 0f, 0f); - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(20f * (player.allDamage + player.minionDamage - 1f)), 6f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), swordDmg, 6f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), swordDmg, 6f, Main.myPlayer, 0f, 0f); } } } diff --git a/Items/Accessories/HeartoftheElements.cs b/Items/Accessories/HeartoftheElements.cs index b13e02dcbf..5ac11c2e5b 100644 --- a/Items/Accessories/HeartoftheElements.cs +++ b/Items/Accessories/HeartoftheElements.cs @@ -62,8 +62,11 @@ namespace CalamityMod.Items.Accessories player.statManaMax2 += 50; player.manaCost *= 0.95f; player.allDamage += 0.08f; + int damage = NPC.downedMoonlord ? 150 : 90; float damageMult = CalamityWorld.downedDoG ? 2f : 1f; + int elementalDmg = (int)(damage * damageMult * player.MinionDamage()); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 1 || player.ownedProjectileCounts[ModContent.ProjectileType()] > 1 || player.ownedProjectileCounts[ModContent.ProjectileType()] > 1 || player.ownedProjectileCounts[ModContent.ProjectileType()] > 1 || player.ownedProjectileCounts[ModContent.ProjectileType()] > 1) @@ -76,23 +79,23 @@ namespace CalamityMod.Items.Accessories } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), (int)((float)damage * damageMult * (player.allDamage + player.minionDamage - 1f)), 2f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), elementalDmg, 2f, Main.myPlayer, 0f, 0f); } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), (int)((float)damage * damageMult * (player.allDamage + player.minionDamage - 1f)), 2f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), elementalDmg, 2f, Main.myPlayer, 0f, 0f); } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), (int)((float)damage * damageMult * (player.allDamage + player.minionDamage - 1f)), 2f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), elementalDmg, 2f, Main.myPlayer, 0f, 0f); } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), (int)((float)damage * damageMult * (player.allDamage + player.minionDamage - 1f)), 2f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), elementalDmg, 2f, Main.myPlayer, 0f, 0f); } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), (int)((float)damage * damageMult * (player.allDamage + player.minionDamage - 1f)), 2f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), elementalDmg, 2f, Main.myPlayer, 0f, 0f); } } else diff --git a/Items/Accessories/LeviathanAmbergris.cs b/Items/Accessories/LeviathanAmbergris.cs index 4efd95bcc2..697706684e 100644 --- a/Items/Accessories/LeviathanAmbergris.cs +++ b/Items/Accessories/LeviathanAmbergris.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Items.Accessories { if (player.whoAmI == Main.myPlayer) { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 50, 5f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(50 * player.AverageDamage()), 5f, player.whoAmI, 0f, 0f); } } int seaCounter = 0; @@ -56,13 +56,13 @@ namespace CalamityMod.Items.Accessories int num = BuffID.Venom; float num2 = 200f; bool flag = seaCounter % 60 == 0; - int num3 = 15; + int num3 = (int)(15 * player.AverageDamage()); int random = Main.rand.Next(5); if (player.whoAmI == Main.myPlayer) { if (random == 0 && player.immune && Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) { - for (int l = 0; l < 200; l++) + for (int l = 0; l < Main.maxNPCs; l++) { NPC nPC = Main.npc[l]; if (nPC.active && !nPC.friendly && nPC.damage > 0 && !nPC.dontTakeDamage && !nPC.buffImmune[num] && Vector2.Distance(player.Center, nPC.Center) <= num2) diff --git a/Items/Accessories/NebulousCore.cs b/Items/Accessories/NebulousCore.cs index 8254989740..9ab9bf429f 100644 --- a/Items/Accessories/NebulousCore.cs +++ b/Items/Accessories/NebulousCore.cs @@ -39,12 +39,12 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.nCore = true; player.allDamage += 0.12f; - int damage = 1500; + int damage = (int)(1500 * player.AverageDamage()); float knockBack = 3f; if (Main.rand.NextBool(15)) { int num = 0; - for (int i = 0; i < 1000; i++) + for (int i = 0; i < Main.maxProjectiles; i++) { if (Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].type == ModContent.ProjectileType()) { @@ -88,7 +88,7 @@ namespace CalamityMod.Items.Accessories } if (flag) { - for (int k = 0; k < 1000; k++) + for (int k = 0; k < Main.maxProjectiles; k++) { if (Main.projectile[k].active && Main.projectile[k].owner == player.whoAmI && Main.projectile[k].type == ModContent.ProjectileType() && (center - Main.projectile[k].Center).Length() < 48f) { diff --git a/Items/Accessories/PlagueHive.cs b/Items/Accessories/PlagueHive.cs index c2c5476abf..c15e1c0389 100644 --- a/Items/Accessories/PlagueHive.cs +++ b/Items/Accessories/PlagueHive.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Items.Accessories int num = ModContent.BuffType(); float num2 = 300f; bool flag = plagueCounter % 60 == 0; - int num3 = 60; + int num3 = (int)(60 * player.AverageDamage()); int random = Main.rand.Next(10); if (player.whoAmI == Main.myPlayer) { diff --git a/Items/Accessories/RottenBrain.cs b/Items/Accessories/RottenBrain.cs index d264ce98f3..d08beaafbb 100644 --- a/Items/Accessories/RottenBrain.cs +++ b/Items/Accessories/RottenBrain.cs @@ -46,12 +46,12 @@ namespace CalamityMod.Items.Accessories num18 = (float)num17 / num18; num15 *= num18; num16 *= num18; - // TODO -- Rotten Brain's projectiles are boosted by magic damage despite being an all class accessory - int num19 = Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), 18, 2f, player.whoAmI, 0f, 0f); + int num19 = Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), (int)(18 * player.AverageDamage()), 2f, player.whoAmI, 0f, 0f); Main.projectile[num19].ai[1] = player.position.Y; Main.projectile[num19].tileCollide = false; Main.projectile[num19].usesLocalNPCImmunity = true; Main.projectile[num19].localNPCHitCooldown = 10; + Main.projectile[num19].magic = false; } } } diff --git a/Items/Accessories/TheAmalgam.cs b/Items/Accessories/TheAmalgam.cs index e735d1ed2a..e7032831d7 100644 --- a/Items/Accessories/TheAmalgam.cs +++ b/Items/Accessories/TheAmalgam.cs @@ -91,7 +91,7 @@ namespace CalamityMod.Items.Accessories { if (player.whoAmI == Main.myPlayer) { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 2000, 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(2000 * player.AverageDamage()), 0f, player.whoAmI, 0f, 0f); } } if (player.immune) @@ -114,10 +114,12 @@ namespace CalamityMod.Items.Accessories num15 *= num18; num16 *= num18; int type = Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int num19 = Projectile.NewProjectile(x, y, num15, num16, type, 2000, 1f, player.whoAmI, 0f, 0f); + int num19 = Projectile.NewProjectile(x, y, num15, num16, type, (int)(2000 * player.AverageDamage()), 1f, player.whoAmI, 0f, 0f); Main.projectile[num19].tileCollide = false; Main.projectile[num19].usesLocalNPCImmunity = true; Main.projectile[num19].localNPCHitCooldown = 10; + Main.projectile[num19].usesIDStaticNPCImmunity = false; + Main.projectile[num19].magic = false; } } } @@ -127,7 +129,7 @@ namespace CalamityMod.Items.Accessories int num = BuffID.Venom; float num2 = 300f; bool flag = seaCounter % 60 == 0; - int num3 = 320; + int num3 = (int)(320 * player.AverageDamage()); int random = Main.rand.Next(5); if (player.whoAmI == Main.myPlayer) { @@ -181,9 +183,7 @@ namespace CalamityMod.Items.Accessories spawn.X = spawn.X + i * 30 - (FireProjectiles * 15); Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-FireAngleSpread / 2 + (FireAngleSpread * i / (float)FireProjectiles))); velocity.X = velocity.X + 3 * Main.rand.NextFloat() - 1.5f; - int projectile = Projectile.NewProjectile(spawn.X, spawn.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), 2000, 5f, Main.myPlayer, 0f, 0f); - Main.projectile[projectile].tileCollide = false; - Main.projectile[projectile].timeLeft = 50; + Projectile.NewProjectile(spawn.X, spawn.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), (int)(2000 * player.AverageDamage()), 5f, Main.myPlayer, 0f, 0f); } } } diff --git a/Items/Accessories/ToxicHeart.cs b/Items/Accessories/ToxicHeart.cs index 95624e8c84..43f5fa212a 100644 --- a/Items/Accessories/ToxicHeart.cs +++ b/Items/Accessories/ToxicHeart.cs @@ -32,13 +32,13 @@ namespace CalamityMod.Items.Accessories int num = ModContent.BuffType(); float num2 = 300f; bool flag = plagueCounter % 60 == 0; - int num3 = 30; + int num3 = (int)(30 * player.AverageDamage()); int random = Main.rand.Next(10); if (player.whoAmI == Main.myPlayer) { if (random == 0) { - for (int l = 0; l < 200; l++) + for (int l = 0; l < Main.maxNPCs; l++) { NPC nPC = Main.npc[l]; if (nPC.active && !nPC.friendly && nPC.damage > 0 && !nPC.dontTakeDamage && !nPC.buffImmune[num] && Vector2.Distance(player.Center, nPC.Center) <= num2) diff --git a/Items/Accessories/VoidofExtinction.cs b/Items/Accessories/VoidofExtinction.cs index cc74f210e7..b19ff08fb0 100644 --- a/Items/Accessories/VoidofExtinction.cs +++ b/Items/Accessories/VoidofExtinction.cs @@ -1,5 +1,4 @@ using CalamityMod.CalPlayer; -using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using System; @@ -87,10 +86,11 @@ namespace CalamityMod.Items.Accessories num18 = (float)num17 / num18; num15 *= num18; num16 *= num18; - int num19 = Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), 40, 5f, player.whoAmI, 0f, 0f); + int num19 = Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), (int)(40 * player.AverageDamage()), 5f, player.whoAmI, 0f, 0f); Main.projectile[num19].ai[1] = player.position.Y; Main.projectile[num19].usesLocalNPCImmunity = true; Main.projectile[num19].localNPCHitCooldown = 60; + Main.projectile[num19].usesIDStaticNPCImmunity = false; } } @@ -120,10 +120,7 @@ namespace CalamityMod.Items.Accessories spawn.X = spawn.X + i * 30 - (FireProjectiles * 15); Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-FireAngleSpread / 2 + (FireAngleSpread * i / (float)FireProjectiles))); velocity.X = velocity.X + 3 * Main.rand.NextFloat() - 1.5f; - // TODO -- Void of Extinction's projectiles are boosted by magic damage despite being an all class accessory - int projectile = Projectile.NewProjectile(spawn.X, spawn.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), 70, 5f, Main.myPlayer, 0f, 0f); - Main.projectile[projectile].tileCollide = false; - Main.projectile[projectile].timeLeft = 50; + Projectile.NewProjectile(spawn.X, spawn.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), (int)(70 * player.AverageDamage()), 5f, Main.myPlayer, 0f, 0f); } } } diff --git a/Items/Accessories/WifeinaBottle.cs b/Items/Accessories/WifeinaBottle.cs index 97056ed62c..e324774e6b 100644 --- a/Items/Accessories/WifeinaBottle.cs +++ b/Items/Accessories/WifeinaBottle.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Items.Accessories } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), (int)(45f * (player.allDamage + player.minionDamage - 1f)), 2f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), (int)(45f * player.MinionDamage()), 2f, Main.myPlayer, 0f, 0f); } } } diff --git a/Items/Accessories/YharimsGift.cs b/Items/Accessories/YharimsGift.cs index e3e5c8f299..bd898b736a 100644 --- a/Items/Accessories/YharimsGift.cs +++ b/Items/Accessories/YharimsGift.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Accessories { if (player.whoAmI == Main.myPlayer) { - int projectile1 = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 350, 5f, player.whoAmI, 0f, 0f); + int projectile1 = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(350 * player.AverageDamage()), 5f, player.whoAmI, 0f, 0f); Main.projectile[projectile1].timeLeft = 60; } dragonTimer = 60; @@ -69,7 +69,7 @@ namespace CalamityMod.Items.Accessories num18 = (float)num17 / num18; num15 *= num18; num16 *= num18; - int num19 = Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), 750, 9f, player.whoAmI, 0f, 0f); + int num19 = Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), (int)(750 * player.AverageDamage()), 9f, player.whoAmI, 0f, 0f); Main.projectile[num19].ai[1] = player.position.Y; Main.projectile[num19].hostile = false; Main.projectile[num19].friendly = true; diff --git a/Items/Armor/DemonshadeHelm.cs b/Items/Armor/DemonshadeHelm.cs index ddac6fe9a8..5975793cd0 100644 --- a/Items/Armor/DemonshadeHelm.cs +++ b/Items/Armor/DemonshadeHelm.cs @@ -1,7 +1,7 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Typeless; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ModLoader; @@ -57,11 +57,7 @@ namespace CalamityMod.Items.Armor } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - float modifier = player.meleeDamage + player.magicDamage + player.rangedDamage + - modPlayer.throwingDamage + player.minionDamage + ((player.allDamage - 1f) * 5f); - - modifier /= 5f; - int damage = (int)(10000 * modifier); + int damage = (int)(10000 * player.AverageDamage()); Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); } } diff --git a/Items/Weapons/Typeless/Aestheticus.cs b/Items/Weapons/Typeless/Aestheticus.cs index 19f795a72b..52bc0d2951 100644 --- a/Items/Weapons/Typeless/Aestheticus.cs +++ b/Items/Weapons/Typeless/Aestheticus.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Weapons.Typeless return new Vector2(10, 10); } - // Lunic Eye scales off of all damage types simultaneously (meaning it scales 5x from universal damage boosts). + // Aestheticus scales off of all damage types simultaneously (meaning it scales 5x from universal damage boosts). public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) { float formula = 5f * (player.allDamage - 1f); diff --git a/NPCs/Bumblebirb/Bumblefuck.cs b/NPCs/Bumblebirb/Bumblefuck.cs index 6f834f438d..2ff5c31134 100644 --- a/NPCs/Bumblebirb/Bumblefuck.cs +++ b/NPCs/Bumblebirb/Bumblefuck.cs @@ -99,7 +99,6 @@ namespace CalamityMod.NPCs.Bumblebirb public override void AI() { - //npc.visualOffset = new Vector2(20f, 50f); CalamityAI.BumblebirbAI(npc, mod); } @@ -226,17 +225,17 @@ namespace CalamityMod.NPCs.Bumblebirb if (phase3 && calamityGlobalNPC.newAI[3] == 1f) { - color = buffColor(color, 0.9f, 0.6f, 0.2f, 1f); + color = CalamityGlobalNPC.buffColor(color, 0.9f, 0.6f, 0.2f, 1f); } else if (phase2 && calamityGlobalNPC.newAI[2] == 1f) { - color = buffColor(color, 0.7f, 0.7f, 0.3f, 1f); + color = CalamityGlobalNPC.buffColor(color, 0.7f, 0.7f, 0.3f, 1f); } else if (phase2 && calamityGlobalNPC.newAI[0] > (float)num150) { float num152 = calamityGlobalNPC.newAI[0] - (float)num150; num152 /= (float)num151; - color = buffColor(color, 1f - 0.3f * num152, 1f - 0.3f * num152, 1f - 0.7f * num152, 1f); + color = CalamityGlobalNPC.buffColor(color, 1f - 0.3f * num152, 1f - 0.3f * num152, 1f - 0.7f * num152, 1f); } int num153 = 10; diff --git a/NPCs/Bumblebirb/Bumblefuck2.cs b/NPCs/Bumblebirb/Bumblefuck2.cs index 9534e5837e..88e2d88af0 100644 --- a/NPCs/Bumblebirb/Bumblefuck2.cs +++ b/NPCs/Bumblebirb/Bumblefuck2.cs @@ -61,7 +61,6 @@ namespace CalamityMod.NPCs.Bumblebirb public override void AI() { - //npc.visualOffset = new Vector2(10, 40); Player player = Main.player[npc.target]; Vector2 vector = npc.Center; npc.damage = npc.defDamage; @@ -361,6 +360,12 @@ namespace CalamityMod.NPCs.Bumblebirb return false; } + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + return true; + } + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index 0eaaac1472..5c27b687bb 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -72,7 +72,7 @@ namespace CalamityMod.NPCs int npcPosY = (int)(npc.position.Y + (float)(npc.height / 2)) / 16; // Barf out enemies - int variable = 5; + int variable = 10; if (calamityGlobalNPC.newAI[3] % 60f == 0f && npcPosX > variable && npcPosY > variable && npcPosX < Main.maxTilesX - variable && npcPosY < Main.maxTilesY - variable) { Main.PlaySound(4, (int)npc.position.X, (int)npc.position.Y, 13); @@ -4139,7 +4139,7 @@ namespace CalamityMod.NPCs while (!WorldGen.SolidTile(num1313, num1314) && (double)num1314 < Main.worldSurface) num1314++; - if ((new Vector2((float)(num1313 * 16 + 8), (float)(num1314 * 16 + 8)) - player.Center).Length() < 1600f) + if ((new Vector2((float)(num1313 * 16 + 8), (float)(num1314 * 16 + 8)) - player.Center).Length() < 1200f) { npc.ai[0] = 4.1f; npc.ai[1] = (float)num1313; @@ -4179,7 +4179,7 @@ namespace CalamityMod.NPCs num1319 = 20f; float num1320 = 10f; - if (vector207.Length() < 10f) + if (vector207.Length() < 50f) npc.ai[0] = 4.2f; vector207.Normalize(); @@ -4206,7 +4206,7 @@ namespace CalamityMod.NPCs float num1323 = 4f; //4 float num1324 = 2f; //2 - if (Main.netMode != NetmodeID.MultiplayerClient && vector208.Length() < 4f) + if (Main.netMode != NetmodeID.MultiplayerClient && vector208.Length() < 20f) { int num1325 = 10; if (Main.expertMode) @@ -4228,7 +4228,7 @@ namespace CalamityMod.NPCs npc.ai[2] = 0f; npc.ai[3] = 0f; - if (NPC.CountNPCS(ModContent.NPCType()) < num1305 && Main.rand.Next(5) != 0) + if (NPC.CountNPCS(ModContent.NPCType()) < num1305 && Main.rand.NextBool(2)) npc.ai[0] = 4f; else if (Collision.SolidCollision(npc.position, npc.width, npc.height)) npc.ai[0] = 1f; @@ -4260,7 +4260,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 vector7 = npc.rotation.ToRotationVector2() * (Vector2.UnitX * (float)npc.direction) * (float)(npc.width + 20) / 2f + vector; - Projectile.NewProjectile(vector7.X, vector7.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, (float)(npc.target + 1)); + Projectile.NewProjectile(vector7.X, vector7.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, phase3 ? 1f : 0f, (float)(npc.target + 1)); } } @@ -4530,7 +4530,7 @@ namespace CalamityMod.NPCs if (npc.ai[0] == -1f) { // Velocity - if(npc.Calamity().newAI[3] == 0f) + if (npc.Calamity().newAI[3] == 0f) npc.velocity *= 0.98f; // Direction @@ -4725,7 +4725,7 @@ namespace CalamityMod.NPCs for (int j = 0; j < num24; j++) { Vector2 arg_E1C_0 = (Vector2.Normalize(npc.velocity) * new Vector2((float)(npc.width + 50) / 2f, (float)npc.height) * 0.75f).RotatedBy((double)(j - (num24 / 2 - 1)) * (double)pie / (double)(float)num24, default) + vector; - Vector2 vector4 = ((float)(Main.rand.NextDouble() * (double)pie) - pie * 0.5f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + Vector2 vector4 = ((float)(Main.rand.NextDouble() * (double)pie) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); int num25 = Dust.NewDust(arg_E1C_0 + vector4, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, vector4.X * 2f, vector4.Y * 2f, 100, default, 1.4f); Main.dust[num25].noGravity = true; Main.dust[num25].noLight = true; @@ -5037,7 +5037,7 @@ namespace CalamityMod.NPCs for (int k = 0; k < num29; k++) { Vector2 arg_1A97_0 = (Vector2.Normalize(npc.velocity) * new Vector2((float)(npc.width + 50) / 2f, (float)npc.height) * 0.75f).RotatedBy((double)(k - (num29 / 2 - 1)) * (double)pie / (double)(float)num29, default) + vector; - Vector2 vector9 = ((float)(Main.rand.NextDouble() * (double)pie) - pie * 0.5f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + Vector2 vector9 = ((float)(Main.rand.NextDouble() * (double)pie) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); int num30 = Dust.NewDust(arg_1A97_0 + vector9, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, vector9.X * 2f, vector9.Y * 2f, 100, default, 1.4f); Main.dust[num30].noGravity = true; Main.dust[num30].noLight = true; @@ -5188,7 +5188,6 @@ namespace CalamityMod.NPCs } // Phase 3 - // Most of this will need to be rewritten else if (npc.ai[0] == 10f && !player.dead) { // Alpha @@ -5331,7 +5330,7 @@ namespace CalamityMod.NPCs for (int m = 0; m < num34; m++) { Vector2 arg_2444_0 = (Vector2.Normalize(npc.velocity) * new Vector2((float)(npc.width + 50) / 2f, (float)npc.height) * 0.75f).RotatedBy((double)(m - (num34 / 2 - 1)) * (double)pie / (double)(float)num34, default) + vector; - Vector2 vector11 = ((float)(Main.rand.NextDouble() * (double)pie) - pie * 0.5f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + Vector2 vector11 = ((float)(Main.rand.NextDouble() * (double)pie) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); int num35 = Dust.NewDust(arg_2444_0 + vector11, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, vector11.X * 2f, vector11.Y * 2f, 100, default, 1.4f); Main.dust[num35].noGravity = true; Main.dust[num35].noLight = true; diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 21d11ed3e2..0e7f9900c7 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -4421,6 +4421,15 @@ namespace CalamityMod.NPCs } return null; } + + public static Color buffColor(Color newColor, float R, float G, float B, float A) + { + newColor.R = (byte)((float)newColor.R * R); + newColor.G = (byte)((float)newColor.G * G); + newColor.B = (byte)((float)newColor.B * B); + newColor.A = (byte)((float)newColor.A * A); + return newColor; + } #endregion #region Get Chat diff --git a/NPCs/Crabulon/CrabShroomGlow.png b/NPCs/Crabulon/CrabShroomGlow.png new file mode 100644 index 0000000000..428836b9f5 Binary files /dev/null and b/NPCs/Crabulon/CrabShroomGlow.png differ diff --git a/NPCs/Crabulon/CrabulonAttackGlow.png b/NPCs/Crabulon/CrabulonAttackGlow.png new file mode 100644 index 0000000000..e0a7336330 Binary files /dev/null and b/NPCs/Crabulon/CrabulonAttackGlow.png differ diff --git a/NPCs/Crabulon/CrabulonIdleAltGlow.png b/NPCs/Crabulon/CrabulonIdleAltGlow.png new file mode 100644 index 0000000000..50feb37a72 Binary files /dev/null and b/NPCs/Crabulon/CrabulonIdleAltGlow.png differ diff --git a/NPCs/Crabulon/CrabulonIdleGlow.png b/NPCs/Crabulon/CrabulonIdleGlow.png new file mode 100644 index 0000000000..ae4fba7a3f Binary files /dev/null and b/NPCs/Crabulon/CrabulonIdleGlow.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index 69e9d56d3b..c73a48afea 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -813,8 +813,7 @@ namespace CalamityMod.NPCs.DevourerofGods player.KillMe(PlayerDeathReason.ByCustomReason(player.name + "'s essence was consumed by the devourer."), 1000.0, 0, false); } - // TODO: don't talk if the player has iframes - if (player.immuneTime > 0 || player.immune) + if (player.immune || player.hurtCooldowns[1] > 0) return; int num = Main.rand.Next(5); diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadS.cs b/NPCs/DevourerofGods/DevourerofGodsHeadS.cs index 073853905a..b547e09030 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHeadS.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHeadS.cs @@ -1201,8 +1201,7 @@ namespace CalamityMod.NPCs.DevourerofGods player.KillMe(PlayerDeathReason.ByCustomReason(player.name + "'s essence was consumed by the devourer."), 1000.0, 0, false); } - // TODO: don't talk if the player has iframes - if (player.immune || player.immuneTime > 0) + if (player.immune || player.hurtCooldowns[1] > 0) return; int num = Main.rand.Next(5); diff --git a/NPCs/OldDuke/OldDuke.cs b/NPCs/OldDuke/OldDuke.cs index 480fcf56ec..2de6ac9d93 100644 --- a/NPCs/OldDuke/OldDuke.cs +++ b/NPCs/OldDuke/OldDuke.cs @@ -180,7 +180,7 @@ namespace CalamityMod.NPCs.OldDuke spriteEffects = SpriteEffects.FlipHorizontally; } Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Vector2 vector11 = new Vector2((float)(texture2D15.Width / 2), (float)(texture2D15.Height / Main.npcFrameCount[npc.type] / 2)); Color color = lightColor; Color color36 = Color.White; float amount9 = 0f; @@ -190,17 +190,17 @@ namespace CalamityMod.NPCs.OldDuke int num151 = 60; if (flag9) { - color = buffColor(color, 0.4f, 0.8f, 0.4f, 1f); + color = CalamityGlobalNPC.buffColor(color, 0.4f, 0.8f, 0.4f, 1f); } else if (flag8) { - color = buffColor(color, 0.5f, 0.7f, 0.5f, 1f); + color = CalamityGlobalNPC.buffColor(color, 0.5f, 0.7f, 0.5f, 1f); } else if (npc.ai[0] == 4f && npc.ai[2] > (float)num150) { float num152 = npc.ai[2] - (float)num150; num152 /= (float)num151; - color = buffColor(color, 1f - 0.5f * num152, 1f - 0.3f * num152, 1f - 0.5f * num152, 1f); + color = CalamityGlobalNPC.buffColor(color, 1f - 0.5f * num152, 1f - 0.3f * num152, 1f - 0.5f * num152, 1f); } int num153 = 10; @@ -355,15 +355,6 @@ namespace CalamityMod.NPCs.OldDuke return false; } - private static Color buffColor(Color newColor, float R, float G, float B, float A) - { - newColor.R = (byte)((float)newColor.R * R); - newColor.G = (byte)((float)newColor.G * G); - newColor.B = (byte)((float)newColor.B * B); - newColor.A = (byte)((float)newColor.A * A); - return newColor; - } - public override void BossLoot(ref string name, ref int potionType) { potionType = ItemID.SuperHealingPotion; @@ -400,7 +391,13 @@ namespace CalamityMod.NPCs.OldDuke CalamityMod.UpdateServerBoolean(); } - public override void OnHitPlayer(Player player, int damage, bool crit) + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + return true; + } + + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(BuffID.Venom, 300, true); player.AddBuff(BuffID.Rabies, 300, true); diff --git a/NPCs/OldDuke/OldDukeSharkron.cs b/NPCs/OldDuke/OldDukeSharkron.cs index 1def4f3bd5..2b46e044e9 100644 --- a/NPCs/OldDuke/OldDukeSharkron.cs +++ b/NPCs/OldDuke/OldDukeSharkron.cs @@ -186,6 +186,12 @@ namespace CalamityMod.NPCs.OldDuke return false; } + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + return true; + } + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(BuffID.Venom, 180, true); diff --git a/NPCs/OldDuke/OldDukeToothBall.cs b/NPCs/OldDuke/OldDukeToothBall.cs index 406c137e5a..78cee23272 100644 --- a/NPCs/OldDuke/OldDukeToothBall.cs +++ b/NPCs/OldDuke/OldDukeToothBall.cs @@ -158,7 +158,13 @@ namespace CalamityMod.NPCs.OldDuke } } } - + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + return true; + } + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(BuffID.Venom, 180, true); diff --git a/NPCs/Yharon/DetonatingFlare.cs b/NPCs/Yharon/DetonatingFlare.cs index 9a52bf2b86..bc4a868751 100644 --- a/NPCs/Yharon/DetonatingFlare.cs +++ b/NPCs/Yharon/DetonatingFlare.cs @@ -1,5 +1,6 @@ using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ID; @@ -237,7 +238,39 @@ namespace CalamityMod.NPCs.Yharon return new Color(255, Main.DiscoG, 53, 0); } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = new Color(255, Main.DiscoG, 53, 0); + float amount9 = 0.5f; + int num153 = 10; + + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, new Rectangle?(npc.frame), color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, new Rectangle?(npc.frame), npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + return false; + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return true; diff --git a/NPCs/Yharon/DetonatingFlare2.cs b/NPCs/Yharon/DetonatingFlare2.cs index 33021330b2..3b711f598e 100644 --- a/NPCs/Yharon/DetonatingFlare2.cs +++ b/NPCs/Yharon/DetonatingFlare2.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ID; @@ -15,7 +16,8 @@ namespace CalamityMod.NPCs.Yharon { DisplayName.SetDefault("Detonating Flame"); Main.npcFrameCount[npc.type] = 5; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { @@ -73,7 +75,35 @@ namespace CalamityMod.NPCs.Yharon return new Color(255, Main.DiscoG, 53, 0); } - public override void OnHitPlayer(Player player, int damage, bool crit) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = new Color(255, Main.DiscoG, 53, 0); + float amount9 = 0.5f; + int num153 = 10; + + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, new Rectangle?(npc.frame), color38, npc.rotation, vector11, npc.scale, SpriteEffects.None, 0f); + } + + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, new Rectangle?(npc.frame), npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, SpriteEffects.None, 0f); + + return false; + } + + public override void OnHitPlayer(Player player, int damage, bool crit) { if (CalamityWorld.revenge) { diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index e645339515..7321f96f2e 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -38,7 +38,7 @@ namespace CalamityMod.NPCs.Yharon private bool enraged = false; private bool protectionBoost = false; private bool moveCloser = false; - private bool phaseOneLoot = false; + private bool phaseOneLoot = true; private bool dropLoot = false; private bool useTornado = true; private int healCounter = 0; @@ -56,7 +56,8 @@ namespace CalamityMod.NPCs.Yharon { DisplayName.SetDefault("Jungle Dragon, Yharon"); Main.npcFrameCount[npc.type] = 7; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { @@ -73,8 +74,6 @@ namespace CalamityMod.NPCs.Yharon aiType = -1; npc.value = Item.buyPrice(1, 50, 0, 0); npc.boss = true; - NPCID.Sets.TrailCacheLength[npc.type] = 8; - NPCID.Sets.TrailingMode[npc.type] = 1; for (int k = 0; k < npc.buffImmune.Length; k++) { @@ -162,14 +161,18 @@ namespace CalamityMod.NPCs.Yharon // Stop rain CalamityMod.StopRain(); - // Start phase 2 or not - if (startSecondAI) + // Variables + bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; + bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; + bool death = CalamityWorld.death || CalamityWorld.bossRushActive; + float pie = (float)Math.PI; + + // Start phase 2 or not + if (startSecondAI) { // Despawn and drop phase 1 loot if (!CalamityWorld.downedBuffedMothron && !CalamityWorld.bossRushActive) { - phaseOneLoot = true; - npc.DeathSound = null; npc.dontTakeDamage = true; @@ -217,15 +220,12 @@ namespace CalamityMod.NPCs.Yharon phaseOneLoot = false; // Start second AI - Yharon_AI2(); + Yharon_AI2(expertMode, revenge, death, pie); return; } // Phase bools - bool death = CalamityWorld.death || CalamityWorld.bossRushActive; - bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; - bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; bool phase2Check = (double)npc.life <= (double)npc.lifeMax * (revenge ? 0.8 : 0.7); bool phase3Check = (double)npc.life <= (double)npc.lifeMax * (revenge ? 0.5 : 0.4); bool phase4Check = (double)npc.life <= (double)npc.lifeMax * (revenge ? 0.25 : 0.2); @@ -242,7 +242,8 @@ namespace CalamityMod.NPCs.Yharon int aiChangeRate = expertMode ? 36 : 38; float npcVelocity = expertMode ? 0.7f : 0.69f; float scaleFactor = expertMode ? 11f : 10.8f; - if (phase4Change || npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) + + if (phase4Change || npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) { npcVelocity = 0.95f; scaleFactor = 14f; @@ -306,7 +307,7 @@ namespace CalamityMod.NPCs.Yharon } // Variables for charging and etc. - int xPos = npc.direction == 1 ? 25 : -25; + int xPos = 60 * npc.direction; int num1454 = 80; int num1455 = 4; float num1456 = 0.3f; @@ -318,7 +319,7 @@ namespace CalamityMod.NPCs.Yharon int num1461 = 120; int num1462 = 4; float scaleFactor13 = 20f; - float num1463 = 6.28318548f / (float)(num1461 / 2); + float num1463 = MathHelper.TwoPi / (float)(num1461 / 2); int num1464 = 75; // Center and target @@ -414,11 +415,11 @@ namespace CalamityMod.NPCs.Yharon // Rotation float npcRotation = (float)Math.Atan2((double)(player.Center.Y - vectorCenter.Y), (double)(player.Center.X - vectorCenter.X)); if (npc.spriteDirection == 1) - npcRotation += 3.14159274f; + npcRotation += pie; if (npcRotation < 0f) - npcRotation += 6.28318548f; - if (npcRotation > 6.28318548f) - npcRotation -= 6.28318548f; + npcRotation += MathHelper.TwoPi; + if (npcRotation > MathHelper.TwoPi) + npcRotation -= MathHelper.TwoPi; if (npc.ai[0] == -1f) npcRotation = 0f; if (npc.ai[0] == 3f) @@ -448,14 +449,14 @@ namespace CalamityMod.NPCs.Yharon if (npc.rotation < npcRotation) { - if ((double)(npcRotation - npc.rotation) > 3.1415926535897931) + if (npcRotation - npc.rotation > pie) npc.rotation -= npcRotationSpeed; else npc.rotation += npcRotationSpeed; } if (npc.rotation > npcRotation) { - if ((double)(npc.rotation - npcRotation) > 3.1415926535897931) + if (npc.rotation - npcRotation > pie) npc.rotation += npcRotationSpeed; else npc.rotation -= npcRotationSpeed; @@ -464,9 +465,9 @@ namespace CalamityMod.NPCs.Yharon if (npc.rotation > npcRotation - npcRotationSpeed && npc.rotation < npcRotation + npcRotationSpeed) npc.rotation = npcRotation; if (npc.rotation < 0f) - npc.rotation += 6.28318548f; - if (npc.rotation > 6.28318548f) - npc.rotation -= 6.28318548f; + npc.rotation += MathHelper.TwoPi; + if (npc.rotation > MathHelper.TwoPi) + npc.rotation -= MathHelper.TwoPi; if (npc.rotation > npcRotation - npcRotationSpeed && npc.rotation < npcRotation + npcRotationSpeed) npc.rotation = npcRotation; @@ -474,6 +475,7 @@ namespace CalamityMod.NPCs.Yharon if (npc.ai[0] != -1f && npc.ai[0] < 9f) { bool colliding = Collision.SolidCollision(npc.position, npc.width, npc.height); + if (colliding) npc.alpha += 15; else @@ -481,6 +483,7 @@ namespace CalamityMod.NPCs.Yharon if (npc.alpha < 0) npc.alpha = 0; + if (npc.alpha > 150) npc.alpha = 150; } @@ -507,10 +510,13 @@ namespace CalamityMod.NPCs.Yharon npc.alpha -= 5; bool colliding = Collision.SolidCollision(npc.position, npc.width, npc.height); + if (colliding) npc.alpha += 15; + if (npc.alpha < 0) npc.alpha = 0; + if (npc.alpha > 150) npc.alpha = 150; } @@ -522,13 +528,14 @@ namespace CalamityMod.NPCs.Yharon for (int num1469 = 0; num1469 < num1468; num1469++) { Vector2 vector169 = Vector2.Normalize(npc.velocity) * new Vector2((float)npc.width / 2f, (float)npc.height) * 0.75f * 0.5f; - vector169 = vector169.RotatedBy((double)((float)(num1469 - (num1468 / 2 - 1)) * 6.28318548f / (float)num1468), default) + npc.Center; + vector169 = vector169.RotatedBy((double)((float)(num1469 - (num1468 / 2 - 1)) * MathHelper.TwoPi / (float)num1468), default) + npc.Center; Vector2 value16 = vector169 - npc.Center; int num1470 = Dust.NewDust(vector169 + value16, 0, 0, 244, value16.X * 2f, value16.Y * 2f, 100, default, 1.4f); Main.dust[num1470].noGravity = true; Main.dust[num1470].noLight = true; Main.dust[num1470].velocity = Vector2.Normalize(value16) * 3f; } + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); } @@ -546,58 +553,51 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 0f && !player.dead) { npc.dontTakeDamage = false; + if (npc.ai[1] == 0f) - { npc.ai[1] = (float)(300 * Math.Sign((vectorCenter - player.Center).X)); - } + Vector2 value17 = player.Center + new Vector2(npc.ai[1], -200f) - vectorCenter; Vector2 vector170 = Vector2.Normalize(value17 - npc.velocity) * scaleFactor; if (npc.velocity.X < vector170.X) { npc.velocity.X += npcVelocity; if (npc.velocity.X < 0f && vector170.X > 0f) - { npc.velocity.X += npcVelocity; - } } else if (npc.velocity.X > vector170.X) { npc.velocity.X -= npcVelocity; if (npc.velocity.X > 0f && vector170.X < 0f) - { npc.velocity.X -= npcVelocity; - } } if (npc.velocity.Y < vector170.Y) { npc.velocity.Y += npcVelocity; if (npc.velocity.Y < 0f && vector170.Y > 0f) - { npc.velocity.Y += npcVelocity; - } } else if (npc.velocity.Y > vector170.Y) { npc.velocity.Y -= npcVelocity; if (npc.velocity.Y > 0f && vector170.Y < 0f) - { npc.velocity.Y -= npcVelocity; - } } + int num1471 = Math.Sign(player.Center.X - vectorCenter.X); if (num1471 != 0) { if (npc.ai[2] == 0f && num1471 != npc.direction) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.direction = num1471; + if (npc.spriteDirection != -npc.direction) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)aiChangeRate) { @@ -623,24 +623,26 @@ namespace CalamityMod.NPCs.Yharon aiState = 3; //tornadoes break; } + if (phase2Check) - { aiState = 4; - } + if (aiState == 1) { npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed; npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + if (num1471 != 0) { npc.direction = num1471; + if (npc.spriteDirection == 1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } } @@ -667,18 +669,21 @@ namespace CalamityMod.NPCs.Yharon npc.ai[0] = 5f; npc.ai[1] = 0f; npc.ai[2] = 0f; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed2; npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + if (num1471 != 0) { npc.direction = num1471; + if (npc.spriteDirection == 1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } } + npc.netUpdate = true; } } @@ -688,14 +693,15 @@ namespace CalamityMod.NPCs.Yharon for (int num1474 = 0; num1474 < num1473; num1474++) { Vector2 vector171 = Vector2.Normalize(npc.velocity) * new Vector2((float)(npc.width + 50) / 2f, (float)npc.height) * 0.75f; - vector171 = vector171.RotatedBy((double)(num1474 - (num1473 / 2 - 1)) * 3.1415926535897931 / (double)(float)num1473, default) + vectorCenter; - Vector2 value18 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + vector171 = vector171.RotatedBy((double)(num1474 - (num1473 / 2 - 1)) * (double)pie / (double)(float)num1473, default) + vectorCenter; + Vector2 value18 = ((float)(Main.rand.NextDouble() * (double)pie) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 244, value18.X * 2f, value18.Y * 2f, 100, default, 1.4f); Main.dust[num1475].noGravity = true; Main.dust[num1475].noLight = true; Main.dust[num1475].velocity /= 4f; Main.dust[num1475].velocity -= npc.velocity; } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)chargeTime) { @@ -709,71 +715,65 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 2f) //fireball attack { if (npc.ai[1] == 0f) - { npc.ai[1] = (float)(300 * Math.Sign((vectorCenter - player.Center).X)); - } + Vector2 value19 = player.Center + new Vector2(npc.ai[1], -200f) - vectorCenter; Vector2 vector172 = Vector2.Normalize(value19 - npc.velocity) * scaleFactor11; if (npc.velocity.X < vector172.X) { npc.velocity.X += num1456; if (npc.velocity.X < 0f && vector172.X > 0f) - { npc.velocity.X += num1456; - } } else if (npc.velocity.X > vector172.X) { npc.velocity.X -= num1456; if (npc.velocity.X > 0f && vector172.X < 0f) - { npc.velocity.X -= num1456; - } } if (npc.velocity.Y < vector172.Y) { npc.velocity.Y += num1456; if (npc.velocity.Y < 0f && vector172.Y > 0f) - { npc.velocity.Y += num1456; - } } else if (npc.velocity.Y > vector172.Y) { npc.velocity.Y -= num1456; if (npc.velocity.Y > 0f && vector172.Y < 0f) - { npc.velocity.Y -= num1456; - } } + if (npc.ai[2] == 0f) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - } + if (npc.ai[2] % (float)num1455 == 0f) //fire flare bombs from mouth { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 vector = Vector2.Normalize(player.Center - vectorCenter) * (float)(npc.width + 20) / 2f + vectorCenter; + if (NPC.CountNPCS(ModContent.NPCType()) < flareCount) - { NPC.NewNPC((int)vector.X + xPos, (int)vector.Y - 15, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); - } + int damage = expertMode ? 75 : 90; Projectile.NewProjectile((int)vector.X + xPos, (int)vector.Y - 15, 0f, 0f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); } } + int num1476 = Math.Sign(player.Center.X - vectorCenter.X); if (num1476 != 0) { npc.direction = num1476; + if (npc.spriteDirection != -npc.direction) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)num1454) { @@ -787,15 +787,16 @@ namespace CalamityMod.NPCs.Yharon { npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + if (npc.ai[2] == (float)(num1457 - 30)) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - } + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == (float)(num1457 - 30)) { Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, (float)(npc.direction * 2), 8f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, (float)(npc.target + 1)); //changed Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, (float)(-(float)npc.direction * 2), 8f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); //changed } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)num1457) { @@ -808,12 +809,13 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 4f) //enter phase 2 { npc.dontTakeDamage = true; + npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + if (npc.ai[2] == (float)(num1458 - 60)) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)num1458) { @@ -830,14 +832,15 @@ namespace CalamityMod.NPCs.Yharon for (int num1474 = 0; num1474 < num1473; num1474++) { Vector2 vector171 = Vector2.Normalize(npc.velocity) * new Vector2((float)(npc.width + 50) / 2f, (float)npc.height) * 0.75f; - vector171 = vector171.RotatedBy((double)(num1474 - (num1473 / 2 - 1)) * 3.1415926535897931 / (double)(float)num1473, default) + vectorCenter; - Vector2 value18 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + vector171 = vector171.RotatedBy((double)(num1474 - (num1473 / 2 - 1)) * (double)pie / (double)(float)num1473, default) + vectorCenter; + Vector2 value18 = ((float)(Main.rand.NextDouble() * (double)pie) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 244, value18.X * 2f, value18.Y * 2f, 100, default, 1.4f); //changed Main.dust[num1475].noGravity = true; Main.dust[num1475].noLight = true; Main.dust[num1475].velocity /= 4f; Main.dust[num1475].velocity -= npc.velocity; } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)chargeTime2) { @@ -854,58 +857,51 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 6f && !player.dead) //phase 2 { npc.dontTakeDamage = false; + if (npc.ai[1] == 0f) - { npc.ai[1] = (float)(300 * Math.Sign((vectorCenter - player.Center).X)); - } + Vector2 value20 = player.Center + new Vector2(npc.ai[1], -200f) - vectorCenter; Vector2 vector175 = Vector2.Normalize(value20 - npc.velocity) * scaleFactor; if (npc.velocity.X < vector175.X) { npc.velocity.X += npcVelocity; if (npc.velocity.X < 0f && vector175.X > 0f) - { npc.velocity.X += npcVelocity; - } } else if (npc.velocity.X > vector175.X) { npc.velocity.X -= npcVelocity; if (npc.velocity.X > 0f && vector175.X < 0f) - { npc.velocity.X -= npcVelocity; - } } if (npc.velocity.Y < vector175.Y) { npc.velocity.Y += npcVelocity; if (npc.velocity.Y < 0f && vector175.Y > 0f) - { npc.velocity.Y += npcVelocity; - } } else if (npc.velocity.Y > vector175.Y) { npc.velocity.Y -= npcVelocity; if (npc.velocity.Y > 0f && vector175.Y < 0f) - { npc.velocity.Y -= npcVelocity; - } } + int num1477 = Math.Sign(player.Center.X - vectorCenter.X); if (num1477 != 0) { if (npc.ai[2] == 0f && num1477 != npc.direction) - { - npc.rotation = 3.14159274f; - } + npc.rotation += pie; + npc.direction = num1477; + if (npc.spriteDirection != -npc.direction) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)aiChangeRate) { @@ -935,24 +931,26 @@ namespace CalamityMod.NPCs.Yharon aiState = 3; break; } + if (phase3Check) - { aiState = 4; - } + if (aiState == 1) { npc.ai[0] = 7f; npc.ai[1] = 0f; npc.ai[2] = 0f; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed; npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + if (num1477 != 0) { npc.direction = num1477; + if (npc.spriteDirection == 1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } } @@ -960,15 +958,17 @@ namespace CalamityMod.NPCs.Yharon { npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * scaleFactor13; npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + if (num1477 != 0) { npc.direction = num1477; + if (npc.spriteDirection == 1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } + npc.ai[0] = 8f; npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -990,15 +990,17 @@ namespace CalamityMod.NPCs.Yharon npc.ai[0] = 11f; npc.ai[1] = 0f; npc.ai[2] = 0f; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed2; npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + if (num1477 != 0) { npc.direction = num1477; + if (npc.spriteDirection == 1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } } @@ -1006,19 +1008,22 @@ namespace CalamityMod.NPCs.Yharon { npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * scaleFactor13; npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + if (num1477 != 0) { npc.direction = num1477; + if (npc.spriteDirection == 1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } + npc.ai[0] = 12f; npc.ai[1] = 0f; npc.ai[2] = 0f; } + npc.netUpdate = true; } } @@ -1028,14 +1033,15 @@ namespace CalamityMod.NPCs.Yharon for (int num1480 = 0; num1480 < num1479; num1480++) { Vector2 vector176 = Vector2.Normalize(npc.velocity) * new Vector2((float)(npc.width + 50) / 2f, (float)npc.height) * 0.75f; - vector176 = vector176.RotatedBy((double)(num1480 - (num1479 / 2 - 1)) * 3.1415926535897931 / (double)(float)num1479, default) + vectorCenter; - Vector2 value21 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + vector176 = vector176.RotatedBy((double)(num1480 - (num1479 / 2 - 1)) * (double)pie / (double)(float)num1479, default) + vectorCenter; + Vector2 value21 = ((float)(Main.rand.NextDouble() * (double)pie) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); int num1481 = Dust.NewDust(vector176 + value21, 0, 0, 244, value21.X * 2f, value21.Y * 2f, 100, default, 1.4f); //changed Main.dust[num1481].noGravity = true; Main.dust[num1481].noLight = true; Main.dust[num1481].velocity /= 4f; Main.dust[num1481].velocity -= npc.velocity; } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)chargeTime) { @@ -1049,24 +1055,26 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 8f) { if (npc.ai[2] == 0f) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - } + if (npc.ai[2] % (float)num1462 == 0f) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 vector = Vector2.Normalize(player.Center - vectorCenter) * (float)(npc.width + 20) / 2f + vectorCenter; + if (NPC.CountNPCS(ModContent.NPCType()) < flareCount) - { NPC.NewNPC((int)vector.X + xPos, (int)vector.Y - 15, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); - } + Projectile.NewProjectile((int)vector.X + xPos, (int)vector.Y - 15, (float)Main.rand.Next(-400, 401) * 0.13f, (float)Main.rand.Next(-30, 31) * 0.13f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); } } + npc.velocity = npc.velocity.RotatedBy((double)(-(double)num1463 * (float)npc.direction), default); npc.rotation -= num1463 * (float)npc.direction; + npc.ai[2] += 1f; if (npc.ai[2] >= (float)num1461) { @@ -1080,14 +1088,13 @@ namespace CalamityMod.NPCs.Yharon { npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + if (npc.ai[2] == (float)(num1457 - 30)) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - } + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == (float)(num1457 - 30)) - { Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, (float)(npc.target + 1)); - } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)num1457) { @@ -1100,12 +1107,13 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 10f) //start phase 3 { npc.dontTakeDamage = true; + npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + if (npc.ai[2] == (float)(num1459 - 60)) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)num1459) { @@ -1122,14 +1130,15 @@ namespace CalamityMod.NPCs.Yharon for (int num1480 = 0; num1480 < num1479; num1480++) { Vector2 vector176 = Vector2.Normalize(npc.velocity) * new Vector2((float)(npc.width + 50) / 2f, (float)npc.height) * 0.75f; - vector176 = vector176.RotatedBy((double)(num1480 - (num1479 / 2 - 1)) * 3.1415926535897931 / (double)(float)num1479, default) + vectorCenter; - Vector2 value21 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + vector176 = vector176.RotatedBy((double)(num1480 - (num1479 / 2 - 1)) * (double)pie / (double)(float)num1479, default) + vectorCenter; + Vector2 value21 = ((float)(Main.rand.NextDouble() * (double)pie) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); int num1481 = Dust.NewDust(vector176 + value21, 0, 0, 244, value21.X * 2f, value21.Y * 2f, 100, default, 1.4f); //changed Main.dust[num1481].noGravity = true; Main.dust[num1481].noLight = true; Main.dust[num1481].velocity /= 4f; Main.dust[num1481].velocity -= npc.velocity; } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)chargeTime2) { @@ -1143,12 +1152,12 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 12f) { if (npc.ai[2] == 0f) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - } + if (npc.ai[2] % (float)num1462 == 0f) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + if (Main.netMode != NetmodeID.MultiplayerClient) { int damage = expertMode ? 75 : 90; @@ -1164,8 +1173,10 @@ namespace CalamityMod.NPCs.Yharon Projectile.NewProjectile((int)vector173.X + xPos, (int)vector173.Y - 15, playerX, playerY, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); } } + npc.velocity = npc.velocity.RotatedBy((double)(-(double)num1463 * (float)npc.direction), default); npc.rotation -= num1463 * (float)npc.direction; + npc.ai[2] += 1f; if (npc.ai[2] >= (float)num1461) { @@ -1182,58 +1193,51 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 13f && !player.dead) { npc.dontTakeDamage = phase5Check; + if (npc.ai[1] == 0f) - { npc.ai[1] = (float)(300 * Math.Sign((vectorCenter - player.Center).X)); - } + Vector2 value20 = player.Center + new Vector2(npc.ai[1], -200f) - vectorCenter; Vector2 vector175 = Vector2.Normalize(value20 - npc.velocity) * scaleFactor; if (npc.velocity.X < vector175.X) { npc.velocity.X += npcVelocity; if (npc.velocity.X < 0f && vector175.X > 0f) - { npc.velocity.X += npcVelocity; - } } else if (npc.velocity.X > vector175.X) { npc.velocity.X -= npcVelocity; if (npc.velocity.X > 0f && vector175.X < 0f) - { npc.velocity.X -= npcVelocity; - } } if (npc.velocity.Y < vector175.Y) { npc.velocity.Y += npcVelocity; if (npc.velocity.Y < 0f && vector175.Y > 0f) - { npc.velocity.Y += npcVelocity; - } } else if (npc.velocity.Y > vector175.Y) { npc.velocity.Y -= npcVelocity; if (npc.velocity.Y > 0f && vector175.Y < 0f) - { npc.velocity.Y -= npcVelocity; - } } + int num1477 = Math.Sign(player.Center.X - vectorCenter.X); if (num1477 != 0) { if (npc.ai[2] == 0f && num1477 != npc.direction) - { - npc.rotation = 3.14159274f; - } + npc.rotation += pie; + npc.direction = num1477; + if (npc.spriteDirection != -npc.direction) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)aiChangeRate) { @@ -1266,24 +1270,26 @@ namespace CalamityMod.NPCs.Yharon aiState = 2; //flare circle break; } + if (phase4Check) - { aiState = 4; - } + if (aiState == 1) { npc.ai[0] = 14f; npc.ai[1] = 0f; npc.ai[2] = 0f; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed; npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + if (num1477 != 0) { npc.direction = num1477; + if (npc.spriteDirection == 1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } } @@ -1291,15 +1297,17 @@ namespace CalamityMod.NPCs.Yharon { npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * scaleFactor13; npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + if (num1477 != 0) { npc.direction = num1477; + if (npc.spriteDirection == 1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } + npc.ai[0] = 15f; npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -1321,15 +1329,17 @@ namespace CalamityMod.NPCs.Yharon npc.ai[0] = 18f; npc.ai[1] = 0f; npc.ai[2] = 0f; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed2; npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + if (num1477 != 0) { npc.direction = num1477; + if (npc.spriteDirection == 1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } } @@ -1337,15 +1347,17 @@ namespace CalamityMod.NPCs.Yharon { npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * scaleFactor13; npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + if (num1477 != 0) { npc.direction = num1477; + if (npc.spriteDirection == 1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } + npc.ai[0] = 19f; npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -1356,24 +1368,27 @@ namespace CalamityMod.NPCs.Yharon npc.ai[1] = 0f; npc.ai[2] = 0f; } + npc.netUpdate = true; } } else if (npc.ai[0] == 14f) //charge { npc.dontTakeDamage = phase5Check; + int num1479 = 7; for (int num1480 = 0; num1480 < num1479; num1480++) { Vector2 vector176 = Vector2.Normalize(npc.velocity) * new Vector2((float)(npc.width + 50) / 2f, (float)npc.height) * 0.75f; - vector176 = vector176.RotatedBy((double)(num1480 - (num1479 / 2 - 1)) * 3.1415926535897931 / (double)(float)num1479, default) + vectorCenter; - Vector2 value21 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + vector176 = vector176.RotatedBy((double)(num1480 - (num1479 / 2 - 1)) * (double)pie / (double)(float)num1479, default) + vectorCenter; + Vector2 value21 = ((float)(Main.rand.NextDouble() * (double)pie) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); int num1481 = Dust.NewDust(vector176 + value21, 0, 0, 244, value21.X * 2f, value21.Y * 2f, 100, default, 1.4f); Main.dust[num1481].noGravity = true; Main.dust[num1481].noLight = true; Main.dust[num1481].velocity /= 4f; Main.dust[num1481].velocity -= npc.velocity; } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)chargeTime) { @@ -1387,26 +1402,29 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 15f) { npc.dontTakeDamage = phase5Check; + if (npc.ai[2] == 0f) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - } + if (npc.ai[2] % (float)num1462 == 0f) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 vector = Vector2.Normalize(player.Center - vectorCenter) * (float)(npc.width + 20) / 2f + vectorCenter; + if (NPC.CountNPCS(ModContent.NPCType()) < flareCount && NPC.CountNPCS(ModContent.NPCType()) < flareCount) - { NPC.NewNPC((int)vector.X + xPos, (int)vector.Y - 15, Main.rand.NextBool(2) ? ModContent.NPCType() : ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); - } + Projectile.NewProjectile((int)vector.X + xPos, (int)vector.Y - 15, (float)Main.rand.Next(-401, 401) * 0.13f, (float)Main.rand.Next(-31, 31) * 0.13f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); //changed Projectile.NewProjectile((int)vector.X + xPos, (int)vector.Y - 15, (float)Main.rand.Next(-31, 31) * 0.13f, (float)Main.rand.Next(-151, 151) * 0.13f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); //changed } } + npc.velocity = npc.velocity.RotatedBy((double)(-(double)num1463 * (float)npc.direction), default); npc.rotation -= num1463 * (float)npc.direction; + npc.ai[2] += 1f; if (npc.ai[2] >= (float)num1461) { @@ -1419,16 +1437,16 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 16f) { npc.dontTakeDamage = phase5Check; + npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + if (npc.ai[2] == (float)(num1457 - 30)) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - } + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == (float)(num1457 - 30)) - { Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, (float)(npc.target + 1)); - } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)num1457) { @@ -1442,40 +1460,35 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 17f) { npc.dontTakeDamage = true; + if (npc.ai[2] < (float)(num1459 - 90)) { bool colliding = Collision.SolidCollision(npc.position, npc.width, npc.height); + if (colliding) - { npc.alpha += 15; - } else - { npc.alpha -= 15; - } + if (npc.alpha < 0) - { npc.alpha = 0; - } + if (npc.alpha > 150) - { npc.alpha = 150; - } } else if (npc.alpha < 255) { npc.alpha += 4; if (npc.alpha > 255) - { npc.alpha = 255; - } } + npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + if (npc.ai[2] == (float)(num1459 - 60)) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)num1459) { @@ -1489,18 +1502,20 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 18f) { npc.dontTakeDamage = phase5Check; + int num1479 = 14; for (int num1480 = 0; num1480 < num1479; num1480++) { Vector2 vector176 = Vector2.Normalize(npc.velocity) * new Vector2((float)(npc.width + 50) / 2f, (float)npc.height) * 0.75f; - vector176 = vector176.RotatedBy((double)(num1480 - (num1479 / 2 - 1)) * 3.1415926535897931 / (double)(float)num1479, default) + vectorCenter; - Vector2 value21 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + vector176 = vector176.RotatedBy((double)(num1480 - (num1479 / 2 - 1)) * (double)pie / (double)(float)num1479, default) + vectorCenter; + Vector2 value21 = ((float)(Main.rand.NextDouble() * (double)pie) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); int num1481 = Dust.NewDust(vector176 + value21, 0, 0, 244, value21.X * 2f, value21.Y * 2f, 100, default, 1.4f); Main.dust[num1481].noGravity = true; Main.dust[num1481].noLight = true; Main.dust[num1481].velocity /= 4f; Main.dust[num1481].velocity -= npc.velocity; } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)chargeTime2) { @@ -1514,13 +1529,14 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 19f) { npc.dontTakeDamage = phase5Check; + if (npc.ai[2] == 0f) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - } + if (npc.ai[2] % (float)num1462 == 0f) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + if (Main.netMode != NetmodeID.MultiplayerClient) { int damage = expertMode ? 75 : 90; @@ -1536,8 +1552,10 @@ namespace CalamityMod.NPCs.Yharon Projectile.NewProjectile((int)vector173.X + xPos, (int)vector173.Y - 15, playerX, playerY, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); } } + npc.velocity = npc.velocity.RotatedBy((double)(-(double)num1463 * (float)npc.direction), default); npc.rotation -= num1463 * (float)npc.direction; + npc.ai[2] += 1f; if (npc.ai[2] >= (float)num1461) { @@ -1551,26 +1569,24 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 20f) { npc.dontTakeDamage = phase5Check; + npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + if (npc.ai[2] == (float)(num1457 - 30)) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - } + if (death) { if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == (float)(num1457 - 30)) - { Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, (float)(npc.target + 1)); - } } else { if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == (float)(num1457 - 30)) - { Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, (float)(npc.target + 1)); - } } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)num1457) { @@ -1586,36 +1602,42 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 21f && !player.dead) { npc.dontTakeDamage = phase5Check; + if (npc.alpha < 225) { npc.alpha += 25; if (npc.alpha > 225) - { npc.alpha = 225; - } } + if (npc.ai[1] == 0f) { teleportLocation = Main.rand.NextBool(2) ? (revenge ? 500 : 600) : (revenge ? -500 : -600); npc.ai[1] = (float)(360 * Math.Sign((vectorCenter - player.Center).X)); } + Vector2 value7 = player.Center + new Vector2(npc.ai[1], (float)teleportLocation) - vectorCenter; //teleport distance Vector2 desiredVelocity = Vector2.Normalize(value7 - npc.velocity) * scaleFactor; npc.SimpleFlyMovement(desiredVelocity, npcVelocity); + int num32 = Math.Sign(player.Center.X - vectorCenter.X); if (num32 != 0) { - if (npc.ai[2] == 0f && num32 != npc.direction) - { - npc.rotation = 3.14159274f; - } + if (npc.ai[2] == 0f && num32 != npc.direction) + { + npc.rotation += pie; + for (int l = 0; l < npc.oldPos.Length; l++) + npc.oldPos[l] = Vector2.Zero; + } + npc.direction = num32; + if (npc.spriteDirection != -npc.direction) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)aiChangeRate) { @@ -1647,24 +1669,26 @@ namespace CalamityMod.NPCs.Yharon aiState = 2; break; } + if (phase5Check) - { - aiState = 4; - } + aiState = 3; + if (aiState == 1) { npc.ai[0] = 22f; npc.ai[1] = 0f; npc.ai[2] = 0f; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed; npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + if (num32 != 0) { npc.direction = num32; + if (npc.spriteDirection == 1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } } @@ -1680,35 +1704,31 @@ namespace CalamityMod.NPCs.Yharon npc.ai[1] = 0f; npc.ai[2] = 0f; } - else if (aiState == 4) - { - npc.ai[0] = 25f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } + npc.netUpdate = true; } } else if (npc.ai[0] == 22f) { npc.dontTakeDamage = phase5Check; + npc.alpha -= 25; if (npc.alpha < 0) - { npc.alpha = 0; - } + int num34 = 7; for (int m = 0; m < num34; m++) { Vector2 vector11 = Vector2.Normalize(npc.velocity) * new Vector2((float)(npc.width + 50) / 2f, (float)npc.height) * 0.75f; - vector11 = vector11.RotatedBy((double)(m - (num34 / 2 - 1)) * 3.1415926535897931 / (double)(float)num34, default) + vectorCenter; - Vector2 value8 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + vector11 = vector11.RotatedBy((double)(m - (num34 / 2 - 1)) * (double)pie / (double)(float)num34, default) + vectorCenter; + Vector2 value8 = ((float)(Main.rand.NextDouble() * (double)pie) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); int num35 = Dust.NewDust(vector11 + value8, 0, 0, 244, value8.X * 2f, value8.Y * 2f, 100, default, 1.4f); Main.dust[num35].noGravity = true; Main.dust[num35].noLight = true; Main.dust[num35].velocity /= 4f; Main.dust[num35].velocity -= npc.velocity; } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)chargeTime) { @@ -1722,43 +1742,47 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 23f) { npc.dontTakeDamage = true; + if (npc.alpha < 225) { npc.alpha += 17; if (npc.alpha > 225) - { npc.alpha = 225; - } } + npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + if (npc.ai[2] == (float)(num1460 / 2)) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - } + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == (float)(num1460 / 2)) { if (npc.ai[1] == 0f) - { npc.ai[1] = (float)(300 * Math.Sign((vectorCenter - player.Center).X)); - } + Vector2 center = player.Center + new Vector2(-npc.ai[1], teleportLocation); //teleport distance vectorCenter = npc.Center = center; + int num36 = Math.Sign(player.Center.X - vectorCenter.X); if (num36 != 0) { if (npc.ai[2] == 0f && num36 != npc.direction) { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + for (int n = 0; n < npc.oldPos.Length; n++) + npc.oldPos[n] = Vector2.Zero; + } + npc.direction = num36; + if (npc.spriteDirection != -npc.direction) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.spriteDirection = -npc.direction; } } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)num1460) { @@ -1766,46 +1790,27 @@ namespace CalamityMod.NPCs.Yharon npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 1f; + if (npc.ai[3] == 5f && Main.netMode != NetmodeID.MultiplayerClient) - { Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, (float)(npc.target + 1)); - } + if (npc.ai[3] >= 20f) //14 - { npc.ai[3] = 0f; - } + npc.netUpdate = true; } } - else if (npc.ai[0] == 24f) - { - npc.dontTakeDamage = phase5Check; - if (npc.ai[2] == 0f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - } - npc.velocity = npc.velocity.RotatedBy((double)(-(double)num1463 * (float)npc.direction), default); - npc.rotation -= num1463 * (float)npc.direction; - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num1461) - { - npc.ai[0] = 21f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 1f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 25f) //start phase 5 + else if (npc.ai[0] == 24f) //start phase 5 { npc.alpha = 0; npc.dontTakeDamage = true; + npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + if (npc.ai[2] == (float)(num1459 - 60)) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - } + npc.ai[2] += 1f; if (npc.ai[2] >= (float)num1459) { @@ -1821,22 +1826,19 @@ namespace CalamityMod.NPCs.Yharon } #region AI2 - public void Yharon_AI2() + public void Yharon_AI2(bool expertMode, bool revenge, bool death, float pie) { - bool death = CalamityWorld.death || CalamityWorld.bossRushActive; - bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; - bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; bool phase2 = (double)npc.life <= (double)npc.lifeMax * (revenge ? 0.85 : 0.75); bool phase3 = (double)npc.life <= (double)npc.lifeMax * (revenge ? 0.6 : 0.5); bool phase4 = (double)npc.life <= (double)npc.lifeMax * (revenge ? 0.2 : 0.1); + if (npc.ai[0] != 8f) { npc.alpha -= 25; if (npc.alpha < 0) - { npc.alpha = 0; - } } + if (!moveCloser) { Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); @@ -1844,34 +1846,35 @@ namespace CalamityMod.NPCs.Yharon music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/DragonGod"); else music = MusicID.LunarBoss; + moveCloser = true; + string key = "Mods.CalamityMod.FlameText"; Color messageColor = Color.Orange; + if (Main.netMode == NetmodeID.SinglePlayer) - { Main.NewText(Language.GetTextValue(key), messageColor); - } else if (Main.netMode == NetmodeID.Server) - { NetMessage.BroadcastChatMessage(NetworkText.FromKey(key), messageColor); - } } if (invincibilityCounter < 900) { phase2 = phase3 = phase4 = false; + invincibilityCounter += 1; + int heal = 5; //900 / 5 = 180 healCounter += 1; if (healCounter >= heal) { healCounter = 0; + if (Main.netMode != NetmodeID.MultiplayerClient) { int healAmt = npc.lifeMax / 200; if (healAmt > npc.lifeMax - npc.life) - { healAmt = npc.lifeMax - npc.life; - } + if (healAmt > 0) { npc.life += healAmt; @@ -1882,9 +1885,7 @@ namespace CalamityMod.NPCs.Yharon } } else - { npc.dontTakeDamage = npc.ai[0] == 9f; - } // Acquire target and determine enrage state if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) @@ -1892,6 +1893,7 @@ namespace CalamityMod.NPCs.Yharon npc.TargetClosest(true); npc.netUpdate = true; } + Player targetData = Main.player[npc.target]; // Despawn @@ -1926,6 +1928,7 @@ namespace CalamityMod.NPCs.Yharon { protectionBoost = false; npc.damage = npc.defDamage; + if (phase4) npc.damage = (int)((float)npc.defDamage * 1.1f); } @@ -1937,9 +1940,8 @@ namespace CalamityMod.NPCs.Yharon float num2 = 1f; int num4 = expertMode ? 110 : 125; if (phase4) - { num4 = (int)((double)num4 * 1.1); - } + float num6 = 0.575f; float scaleFactor = 10f; float chargeTime = 34f; @@ -1956,8 +1958,9 @@ namespace CalamityMod.NPCs.Yharon float num18 = 60f; float num19 = num15 + (float)num17 + num18; float num20 = 60f; - float num22 = 6.28318548f * (1f / num20); + float num22 = MathHelper.TwoPi * (1f / num20); float scaleFactor5 = 37.25f; + if (npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) { num6 = 0.7f; @@ -1982,16 +1985,12 @@ namespace CalamityMod.NPCs.Yharon scaleFactor4 *= velocityMult; scaleFactor5 *= velocityMult; } + float num25 = 20f; - float arg_F9_0 = npc.ai[0]; - float num26; if (npc.ai[0] == 0f) { - float[] expr_115_cp_0 = npc.ai; - int expr_115_cp_1 = 1; - num26 = expr_115_cp_0[expr_115_cp_1] + 1f; - expr_115_cp_0[expr_115_cp_1] = num26; - if (num26 >= 10f) + npc.ai[1] += 1f; + if (npc.ai[1] >= 10f) { npc.ai[1] = 0f; npc.ai[0] = 1f; @@ -2002,9 +2001,8 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 1f) { if (npc.ai[2] == 0f) - { npc.ai[2] = (float)((npc.Center.X < targetData.Center.X) ? 1 : -1); - } + Vector2 destination = targetData.Center + new Vector2(-npc.ai[2] * 300f, -200f); Vector2 desiredVelocity = npc.DirectionTo(destination) * scaleFactor; @@ -2013,11 +2011,9 @@ namespace CalamityMod.NPCs.Yharon int num27 = (npc.Center.X < targetData.Center.X) ? 1 : -1; npc.direction = npc.spriteDirection = num27; - float[] expr_225_cp_0 = npc.ai; - int expr_225_cp_1 = 1; - num26 = expr_225_cp_0[expr_225_cp_1] + 1f; - expr_225_cp_0[expr_225_cp_1] = num26; - if (num26 >= 30f) + + npc.ai[1] += 1f; + if (npc.ai[1] >= 30f) { int num28 = 1; if (phase4) @@ -2159,10 +2155,12 @@ namespace CalamityMod.NPCs.Yharon break; } } + npc.ai[0] = (float)num28; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 1f; + switch (secondPhasePhase) { case 1: @@ -2196,24 +2194,20 @@ namespace CalamityMod.NPCs.Yharon } break; } + npc.netUpdate = true; + float aiLimit = 10f; if (phase4) - { aiLimit = 4f; - } else if (phase3) - { aiLimit = 16f; - } else if (phase2) - { aiLimit = 11f; - } + if (npc.ai[3] >= aiLimit) - { npc.ai[3] = 0f; - } + switch (num28) { case 2: //charge @@ -2221,11 +2215,12 @@ namespace CalamityMod.NPCs.Yharon Vector2 vector = npc.DirectionTo(targetData.Center); npc.spriteDirection = (vector.X > 0f) ? 1 : -1; npc.rotation = vector.ToRotation(); + if (npc.spriteDirection == -1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.velocity = vector * chargeSpeed; + break; } case 3: //fireballs @@ -2233,6 +2228,7 @@ namespace CalamityMod.NPCs.Yharon Vector2 vector2 = new Vector2((float)((targetData.Center.X > npc.Center.X) ? 1 : -1), 0f); npc.spriteDirection = (vector2.X > 0f) ? 1 : -1; npc.velocity = vector2 * -2f; + break; } case 5: //spin move @@ -2240,11 +2236,12 @@ namespace CalamityMod.NPCs.Yharon Vector2 vector3 = npc.DirectionTo(targetData.Center); npc.spriteDirection = (vector3.X > 0f) ? 1 : -1; npc.rotation = vector3.ToRotation(); + if (npc.spriteDirection == -1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.velocity = vector3 * scaleFactor5; + break; } case 7: //fast charge @@ -2252,11 +2249,12 @@ namespace CalamityMod.NPCs.Yharon Vector2 vector = npc.DirectionTo(targetData.Center); npc.spriteDirection = (vector.X > 0f) ? 1 : -1; npc.rotation = vector.ToRotation(); + if (npc.spriteDirection == -1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.velocity = vector * chargeSpeed2; + break; } } @@ -2265,26 +2263,23 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 2f) { if (npc.ai[1] == 1f) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - } + int num1473 = 7; for (int num1474 = 0; num1474 < num1473; num1474++) { Vector2 vector171 = Vector2.Normalize(npc.velocity) * new Vector2((float)(npc.width + 50) / 2f, (float)npc.height) * 0.75f; - vector171 = vector171.RotatedBy((double)(num1474 - (num1473 / 2 - 1)) * 3.1415926535897931 / (double)(float)num1473, default) + npc.Center; - Vector2 value18 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + vector171 = vector171.RotatedBy((double)(num1474 - (num1473 / 2 - 1)) * (double)pie / (double)(float)num1473, default) + npc.Center; + Vector2 value18 = ((float)(Main.rand.NextDouble() * (double)pie) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 244, value18.X * 2f, value18.Y * 2f, 100, default, 1.4f); Main.dust[num1475].noGravity = true; Main.dust[num1475].noLight = true; Main.dust[num1475].velocity /= 4f; Main.dust[num1475].velocity -= npc.velocity; } - float[] expr_498_cp_0 = npc.ai; - int expr_498_cp_1 = 1; - num26 = expr_498_cp_0[expr_498_cp_1] + 1f; - expr_498_cp_0[expr_498_cp_1] = num26; - if (num26 >= chargeTime) + + npc.ai[1] += 1f; + if (npc.ai[1] >= chargeTime) { npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -2293,40 +2288,39 @@ namespace CalamityMod.NPCs.Yharon } else if (npc.ai[0] == 3f) //fireball spit { - npc.ai[1] += 1f; int num29 = (npc.Center.X < targetData.Center.X) ? 1 : -1; npc.ai[2] = (float)num29; - if (npc.ai[1] < num11) + + npc.ai[1] += 1f; + if (npc.ai[1] < num11) { Vector2 vector4 = targetData.Center + new Vector2((float)num29 * -600f, -250f); Vector2 value = npc.DirectionTo(vector4) * 12f; + if (npc.Distance(vector4) < 12f) - { npc.Center = vector4; - } else - { npc.position += value; - } + if (Vector2.Distance(vector4, npc.Center) < 16f) - { npc.ai[1] = num11 - 1f; - } + num2 = 1.5f; } + if (npc.ai[1] == num11) { int num30 = (targetData.Center.X > npc.Center.X) ? 1 : -1; npc.velocity = new Vector2((float)num30, 0f) * 22f; //10f npc.direction = npc.spriteDirection = num30; } + if (npc.ai[1] >= num11) { if (npc.ai[1] % 8 == 0 && Main.netMode != NetmodeID.MultiplayerClient) { float num33 = 30f; - Vector2 position = npc.Center + new Vector2((110f + num33) * (float)npc.direction, -20f).RotatedBy((double)npc.rotation, - default); + Vector2 position = npc.Center + new Vector2((110f + num33) * (float)npc.direction, -20f).RotatedBy((double)npc.rotation, default); float speed = 0.01f; Vector2 vectorShoot = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f + 30f); float playerX = targetData.Center.X - vectorShoot.X; @@ -2337,12 +2331,13 @@ namespace CalamityMod.NPCs.Yharon playerY *= playerXY; Projectile.NewProjectile(position.X, position.Y, playerX, playerY, ModContent.ProjectileType(), num4, 0f, Main.myPlayer, 1f, 0f); } + num2 = 1.5f; + if (Math.Abs(targetData.Center.X - npc.Center.X) > 550f && Math.Abs(npc.velocity.X) < 20f) - { npc.velocity.X += (float)Math.Sign(npc.velocity.X) * 0.5f; - } } + if (npc.ai[1] >= num13) { npc.ai[0] = 1f; @@ -2354,17 +2349,20 @@ namespace CalamityMod.NPCs.Yharon { int num31 = (npc.Center.X < targetData.Center.X) ? 1 : -1; npc.ai[2] = (float)num31; + if (npc.ai[1] < num15) { Vector2 vector5 = targetData.Center + new Vector2((float)num31 * -1500f, -350f); Vector2 value2 = npc.DirectionTo(vector5) * scaleFactor3; + npc.velocity = Vector2.Lerp(npc.velocity, value2, 0.0333333351f); + int num32 = (npc.Center.X < targetData.Center.X) ? 1 : -1; npc.direction = npc.spriteDirection = num32; + if (Vector2.Distance(vector5, npc.Center) < 16f) - { npc.ai[1] = num15 - 1f; - } + num2 = 1.5f; } else if (npc.ai[1] == num15) @@ -2372,35 +2370,34 @@ namespace CalamityMod.NPCs.Yharon Vector2 vector6 = npc.DirectionTo(targetData.Center); vector6.Y *= 0.25f; vector6 = vector6.SafeNormalize(Vector2.UnitX * (float)npc.direction); + npc.spriteDirection = (vector6.X > 0f) ? 1 : -1; npc.rotation = vector6.ToRotation(); + if (npc.spriteDirection == -1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + npc.velocity = vector6 * scaleFactor4; } else { npc.position.X = npc.position.X + npc.DirectionTo(targetData.Center).X * 7f; npc.position.Y = npc.position.Y + npc.DirectionTo(targetData.Center + new Vector2(0f, -400f)).Y * 6f; + if (npc.ai[1] <= num19 - num18) - { num2 = 1.5f; - } + float num33 = 30f; - Vector2 position = npc.Center + new Vector2((110f + num33) * (float)npc.direction, -20f).RotatedBy((double)npc.rotation, - default); + Vector2 position = npc.Center + new Vector2((110f + num33) * (float)npc.direction, -20f).RotatedBy((double)npc.rotation, default); int num34 = (int)(npc.ai[1] - num15 + 1f); + if (num34 <= num17 && num34 % num16 == 0 && Main.netMode != NetmodeID.MultiplayerClient) - { Projectile.NewProjectile(position, npc.velocity, ModContent.ProjectileType(), num4, 0f, Main.myPlayer, 0f, 0f); - } } + if (npc.ai[1] > num19 - num18) - { npc.velocity.Y -= 0.1f; - } + npc.ai[1] += 1f; if (npc.ai[1] >= num19) { @@ -2412,26 +2409,26 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 5f) //spin 2 win { npc.velocity = npc.velocity.RotatedBy((double)(-(double)num22 * (float)npc.direction), default); + npc.position.Y = npc.position.Y - 0.1f; npc.position += npc.DirectionTo(targetData.Center) * 10f; + npc.rotation -= num22 * (float)npc.direction; + num2 *= 0.7f; + if (npc.ai[1] == 1f) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - } - float[] expr_B0F_cp_0 = npc.ai; - int expr_B0F_cp_1 = 1; - num26 = expr_B0F_cp_0[expr_B0F_cp_1] + 1f; - expr_B0F_cp_0[expr_B0F_cp_1] = num26; - if (Main.netMode != NetmodeID.MultiplayerClient) + + npc.ai[1] += 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) { if (npc.ai[1] % 12 == 0) { float num33 = 30f; - Vector2 position = npc.Center + new Vector2((110f + num33) * (float)npc.direction, -20f).RotatedBy((double)npc.rotation, - default); + Vector2 position = npc.Center + new Vector2((110f + num33) * (float)npc.direction, -20f).RotatedBy((double)npc.rotation, default); Projectile.NewProjectile(position, npc.velocity, ModContent.ProjectileType(), num4, 0f, Main.myPlayer, 0f, 0f); + if (phase4) { float speed = 0.01f; @@ -2445,13 +2442,15 @@ namespace CalamityMod.NPCs.Yharon Projectile.NewProjectile(position.X, position.Y, playerX, playerY, ModContent.ProjectileType(), num4, 0f, Main.myPlayer, 0f, 0f); } } + if (npc.ai[1] == 45f && phase4 && useTornado) { useTornado = false; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, (float)(npc.target + 1)); } } - if (num26 >= num20) + + if (npc.ai[1] >= num20) { npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -2466,8 +2465,10 @@ namespace CalamityMod.NPCs.Yharon Vector2 destination2 = targetData.Center + new Vector2(0f, -200f); Vector2 desiredVelocity2 = npc.DirectionTo(destination2) * scaleFactor * 2f; npc.SimpleFlyMovement(desiredVelocity2, num6 * 2f); + int num35 = (npc.Center.X < targetData.Center.X) ? 1 : -1; npc.direction = npc.spriteDirection = num35; + npc.ai[2] += 1f; if (npc.Distance(targetData.Center) < 1000f || npc.ai[2] >= 180f) //450f { @@ -2478,46 +2479,47 @@ namespace CalamityMod.NPCs.Yharon else { if (npc.ai[1] == 1f) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - } + if (npc.ai[1] < num25) - { npc.velocity *= 0.95f; - } else - { npc.velocity *= 0.98f; - } + if (npc.ai[1] == num25) { if (npc.velocity.Y > 0f) - { npc.velocity.Y /= 3f; - } + npc.velocity.Y -= 3f; } + num2 *= 0.85f; + bool flag3 = npc.ai[1] == 20f || npc.ai[1] == 45f || npc.ai[1] == 70f; int flareCount = NPC.CountNPCS(ModContent.NPCType()) + NPC.CountNPCS(ModContent.NPCType()); + if (flareCount > 5) - { flag3 = false; - } + if (flag3 && Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector7 = npc.Center + (6.28318548f * Main.rand.NextFloat()).ToRotationVector2() * new Vector2(2f, 1f) * 100f * (0.6f + Main.rand.NextFloat() * 0.4f); - if (Vector2.Distance(vector7, targetData.Center) > 100f) + Vector2 vector7 = npc.Center + (MathHelper.TwoPi * Main.rand.NextFloat()).ToRotationVector2() * new Vector2(2f, 1f) * 100f * (0.6f + Main.rand.NextFloat() * 0.4f); + + if (Vector2.Distance(vector7, targetData.Center) > 100f) { Point point2 = vector7.ToPoint(); NPC.NewNPC(point2.X, point2.Y, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); NPC.NewNPC(point2.X, point2.Y, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); } + NPC.NewNPC((int)npc.Center.X + (Main.rand.NextBool(2) ? 100 : -100), (int)npc.Center.Y - 100, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); NPC.NewNPC((int)npc.Center.X + (Main.rand.NextBool(2) ? 100 : -100), (int)npc.Center.Y - 100, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); } + npc.ai[1] += 1f; } + if (npc.ai[1] >= 90f) { if (Main.netMode != NetmodeID.MultiplayerClient) @@ -2525,6 +2527,7 @@ namespace CalamityMod.NPCs.Yharon Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, (float)(npc.target + 1)); Boom(600, num4); } + npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -2533,26 +2536,23 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 7f) //speedee chargee { if (npc.ai[1] == 1f) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - } + int num1473 = 7; for (int num1474 = 0; num1474 < num1473; num1474++) { Vector2 vector171 = Vector2.Normalize(npc.velocity) * new Vector2((float)(npc.width + 50) / 2f, (float)npc.height) * 0.75f; - vector171 = vector171.RotatedBy((double)(num1474 - (num1473 / 2 - 1)) * 3.1415926535897931 / (double)(float)num1473, default) + npc.Center; - Vector2 value18 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + vector171 = vector171.RotatedBy((double)(num1474 - (num1473 / 2 - 1)) * (double)pie / (double)(float)num1473, default) + npc.Center; + Vector2 value18 = ((float)(Main.rand.NextDouble() * (double)pie) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 244, value18.X * 2f, value18.Y * 2f, 100, default, 1.4f); Main.dust[num1475].noGravity = true; Main.dust[num1475].noLight = true; Main.dust[num1475].velocity /= 4f; Main.dust[num1475].velocity -= npc.velocity; } - float[] expr_498_cp_0 = npc.ai; - int expr_498_cp_1 = 1; - num26 = expr_498_cp_0[expr_498_cp_1] + 1f; - expr_498_cp_0[expr_498_cp_1] = num26; - if (num26 >= chargeTime2) + + npc.ai[1] += 1f; + if (npc.ai[1] >= chargeTime2) { npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -2562,32 +2562,32 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 8f) //teleport { Vector2 npcCenter = npc.Center; + if (npc.alpha < 255) { npc.alpha += 17; if (npc.alpha > 255) - { npc.alpha = 255; - } } + npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + if (npc.ai[2] == 15f) - { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - } + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == 15f) { if (npc.ai[1] == 0f) - { npc.ai[1] = (float)(450 * Math.Sign((npcCenter - targetData.Center).X)); - } + teleportLocation = Main.rand.NextBool(2) ? (revenge ? 500 : 600) : (revenge ? -500 : -600); Vector2 center = targetData.Center + new Vector2(-npc.ai[1], (float)teleportLocation); //teleport distance npcCenter = npc.Center = center; } + npc.ai[2] += 1f; - if (npc.ai[2] >= 25f) + if (npc.ai[2] >= 30f) { npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -2598,13 +2598,14 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 9f) //enter next phase { npc.velocity *= 0.95f; + Vector2 vector = npc.DirectionTo(targetData.Center); npc.spriteDirection = (vector.X > 0f) ? 1 : -1; npc.rotation = vector.ToRotation(); + if (npc.spriteDirection == -1) - { - npc.rotation += 3.14159274f; - } + npc.rotation += pie; + if (npc.ai[2] == 120f) { if (phase4) @@ -2628,8 +2629,10 @@ namespace CalamityMod.NPCs.Yharon proj = x; } } + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); } + npc.ai[2] += 1f; if (npc.ai[2] >= 180f) { @@ -2640,25 +2643,21 @@ namespace CalamityMod.NPCs.Yharon npc.netUpdate = true; } } + npc.localAI[0] += num2; if (npc.localAI[0] >= 36f) - { npc.localAI[0] = 0f; - } + if (num != -1) - { npc.localAI[0] = (float)(num * 4); - } - float[] expr_11FC_cp_0 = npc.localAI; - int expr_11FC_cp_1 = 1; - num26 = expr_11FC_cp_0[expr_11FC_cp_1] + 1f; - expr_11FC_cp_0[expr_11FC_cp_1] = num26; - if (num26 >= 60f) - { + + npc.localAI[1] += 1f; + if (npc.localAI[1] >= 60f) npc.localAI[1] = 0f; - } + float num42 = npc.DirectionTo(targetData.Center).ToRotation(); float num43 = 0.04f; + switch ((int)npc.ai[0]) { case 2: @@ -2671,116 +2670,292 @@ namespace CalamityMod.NPCs.Yharon case 3: num43 = 0.01f; num42 = 0f; + if (npc.spriteDirection == -1) - { - num42 -= 3.14159274f; - } + num42 -= pie; + if (npc.ai[1] >= num11) { - num42 += (float)npc.spriteDirection * 3.14159274f / 12f; + num42 += (float)npc.spriteDirection * pie / 12f; num43 = 0.05f; } + break; case 4: num43 = 0.01f; - num42 = 3.14159274f; + num42 = pie; + if (npc.spriteDirection == 1) - { - num42 += 3.14159274f; - } + num42 += pie; + break; case 6: num43 = 0.02f; num42 = 0f; + if (npc.spriteDirection == -1) - { - num42 -= 3.14159274f; - } + num42 -= pie; + break; } + if (npc.spriteDirection == -1) - { - num42 += 3.14159274f; - } + num42 += pie; + if (num43 != 0f) - { npc.rotation = npc.rotation.AngleTowards(num42, num43); - } } #endregion #region Drawing - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Texture2D texture = Main.npcTexture[npc.type]; - Rectangle frame6 = npc.frame; - Color color9 = Lighting.GetColor((int)((double)npc.position.X + (double)npc.width * 0.5) / 16, (int)(((double)npc.position.Y + (double)npc.height * 0.5) / 16.0)); - int num156 = texture.Height / Main.npcFrameCount[npc.type]; - int y3 = num156 * (int)npc.frameCounter; - Rectangle rectangle = new Rectangle(0, y3, texture.Width, num156); - Vector2 origin2 = rectangle.Size() / 2f; - int num157 = 8; - int num158 = 2; - int num159 = 1; - float num160 = 0f; - int num161 = num159; - if (startSecondAI && !phaseOneLoot) - { - bool drawAfterImage2 = (npc.ai[0] == 2f || npc.ai[0] == 3f || npc.ai[0] == 4f || npc.ai[0] == 5f || npc.ai[0] == 7f) && Lighting.NotRetro; - SpriteEffects spriteEffects2 = spriteEffects ^ SpriteEffects.FlipHorizontally; - if (invincibilityCounter < 900) - { - color9 = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); - } - Color alpha16 = npc.GetAlpha(color9); - while (drawAfterImage2 && ((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157))) - { - goto IL_6899; - IL_6881: - num161 += num158; - continue; - IL_6899: - float num164 = (float)(num157 - num161); - if (num158 < 0) - { - num164 = (float)(num159 - num161); - } - alpha16 *= num164 / ((float)NPCID.Sets.TrailCacheLength[npc.type] * 1.5f); //1.5 - Vector2 value4 = npc.oldPos[num161]; - float num165 = npc.rotation; - Main.spriteBatch.Draw(texture, value4 + npc.Size / 2f - Main.screenPosition + new Vector2(0, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(frame6), alpha16, num165 + npc.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects2.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, npc.scale, spriteEffects2, 0f); - goto IL_6881; - } - Main.spriteBatch.Draw(texture, npc.Center - Main.screenPosition + new Vector2(0, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(frame6), npc.GetAlpha(color9), npc.rotation, npc.frame.Size() / 2, npc.scale, spriteEffects2, 0); - return false; - } - Color alpha15 = npc.GetAlpha(color9); - bool drawAfterImage = (npc.ai[0] == 1f || npc.ai[0] == 5f || npc.ai[0] == 7f || npc.ai[0] == 8f || npc.ai[0] == 11f || npc.ai[0] == 12f || - npc.ai[0] == 14f || npc.ai[0] == 15f || npc.ai[0] == 18f || npc.ai[0] == 19f || npc.ai[0] == 22f) && Lighting.NotRetro; - while (drawAfterImage && ((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157))) - { - goto IL_6899; - IL_6881: - num161 += num158; - continue; - IL_6899: - float num164 = (float)(num157 - num161); - if (num158 < 0) - { - num164 = (float)(num159 - num161); - } - alpha15 *= num164 / ((float)NPCID.Sets.TrailCacheLength[npc.type] * 1.5f); //1.5 - Vector2 value4 = npc.oldPos[num161]; - float num165 = npc.rotation; - Main.spriteBatch.Draw(texture, value4 + npc.Size / 2f - Main.screenPosition + new Vector2(0, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(frame6), alpha15, num165 + npc.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, npc.scale, spriteEffects, 0f); - goto IL_6881; - } - Main.spriteBatch.Draw(texture, npc.Center - Main.screenPosition + new Vector2(0, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(frame6), npc.GetAlpha(color9), npc.rotation, npc.frame.Size() / 2, npc.scale, spriteEffects, 0); + bool idlePhases = (!startSecondAI && (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f || npc.ai[0] == 21f)) || (startSecondAI && (npc.ai[0] == 5f || npc.ai[0] < 2f)); + bool chargingOrSpawnPhases = (!startSecondAI && (npc.ai[0] == 1f || npc.ai[0] == 5f || npc.ai[0] == 7f || npc.ai[0] == 11f || npc.ai[0] == 14f || npc.ai[0] == 18f || npc.ai[0] == 22f)) || + (startSecondAI && (npc.ai[0] == 6f || npc.ai[0] == 2f || npc.ai[0] == 7f)); + bool projectileOrCirclePhases = (!startSecondAI && (npc.ai[0] == 2f || npc.ai[0] == 8f || npc.ai[0] == 12f || npc.ai[0] == 15f || npc.ai[0] == 19f)) || + (startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 3f)); + bool tornadoPhase = !startSecondAI && (npc.ai[0] == 3f || npc.ai[0] == 9f || npc.ai[0] == -1f || npc.ai[0] == 16f || npc.ai[0] == 20f); + bool newPhasePhase = (!startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 10f || npc.ai[0] == 17f || npc.ai[0] == 24f)) || (startSecondAI && npc.ai[0] == 9f); + bool pauseAfterTeleportPhase = (!startSecondAI && npc.ai[0] == 23f) || (startSecondAI && npc.ai[0] == 8f); + bool ai2 = startSecondAI && !phaseOneLoot; + + SpriteEffects spriteEffects = ai2 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = ai2 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + + Texture2D texture = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(texture.Width / 2), (float)(texture.Height / Main.npcFrameCount[npc.type] / 2)); + Color color = lightColor; + Color invincibleColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); + Color color36 = Color.White; + + float amount9 = 0f; + bool invincible = ai2 && invincibilityCounter < 900; + bool flag8 = npc.ai[0] > 5f; + bool flag9 = npc.ai[0] > 12f; + bool flag10 = npc.ai[0] > 20f || startSecondAI; + int num150 = 120; + int num151 = 60; + + if (flag10) + color = CalamityGlobalNPC.buffColor(color, 0.9f, 0.7f, 0.3f, 1f); + else if (flag9) + color = CalamityGlobalNPC.buffColor(color, 0.8f, 0.7f, 0.4f, 1f); + else if (flag8) + color = CalamityGlobalNPC.buffColor(color, 0.7f, 0.7f, 0.5f, 1f); + else if (npc.ai[0] == 4f && npc.ai[2] > (float)num150) + { + float num152 = npc.ai[2] - (float)num150; + num152 /= (float)num151; + color = CalamityGlobalNPC.buffColor(color, 1f - 0.3f * num152, 1f - 0.3f * num152, 1f - 0.5f * num152, 1f); + } + + int num153 = 10; + int num154 = 2; + if (npc.ai[0] == -1f) + num153 = 0; + if (idlePhases) + num153 = 7; + + if (invincible) + color36 = invincibleColor; + else if (chargingOrSpawnPhases) + { + color36 = Color.Red; + amount9 = 0.5f; + } + else + color = lightColor; + + for (int num155 = 1; num155 < num153; num155 += num154) + { + Color color38 = color; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + spriteBatch.Draw(texture, vector41, new Rectangle?(npc.frame), color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + + int num156 = 0; + float num157 = 0f; + float scaleFactor9 = 0f; + + if (npc.ai[0] == -1f) + num156 = 0; + + if (tornadoPhase) + { + int num158 = 60; + int num159 = 30; + if (npc.ai[2] > (float)num158) + { + num156 = 6; + num157 = 1f - (float)Math.Cos((double)((npc.ai[2] - (float)num158) / (float)num159 * MathHelper.TwoPi)); + num157 /= 3f; + scaleFactor9 = 40f; + } + } + + if (newPhasePhase && npc.ai[2] > (float)num150) + { + num156 = 6; + num157 = 1f - (float)Math.Cos((double)((npc.ai[2] - (float)num150) / (float)num151 * MathHelper.TwoPi)); + num157 /= 3f; + scaleFactor9 = 60f; + } + + if (pauseAfterTeleportPhase) + { + num156 = 6; + num157 = 1f - (float)Math.Cos((double)(npc.ai[2] / 30f * MathHelper.TwoPi)); + num157 /= 3f; + scaleFactor9 = 20f; + } + + for (int num160 = 0; num160 < num156; num160++) + { + Color color39 = lightColor; + color39 = Color.Lerp(color39, color36, amount9); + color39 = npc.GetAlpha(color39); + color39 *= 1f - num157; + Vector2 vector42 = npc.Center + ((float)num160 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; + vector42 -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector42 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + spriteBatch.Draw(texture, vector42, new Rectangle?(npc.frame), color39, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + spriteBatch.Draw(texture, vector43, new Rectangle?(npc.frame), (invincible ? invincibleColor : npc.GetAlpha(lightColor)), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + if (flag8 || npc.ai[0] == 4f || startSecondAI) + { + texture = ModContent.GetTexture("CalamityMod/NPCs/Yharon/YharonGlowOrange"); + Color color40 = Color.Lerp(Color.White, (invincible ? invincibleColor : Color.Orange), 0.5f); + color36 = invincible ? invincibleColor : Color.Orange; + + Texture2D texture2 = ModContent.GetTexture("CalamityMod/NPCs/Yharon/YharonGlowGreen"); + Color color43 = Color.Lerp(Color.White, (invincible ? invincibleColor : Color.Chartreuse), 0.5f); + Color color44 = invincible ? invincibleColor : Color.Chartreuse; + + Texture2D texture3 = ModContent.GetTexture("CalamityMod/NPCs/Yharon/YharonGlowPurple"); + Color color45 = Color.Lerp(Color.White, (invincible ? invincibleColor : Color.BlueViolet), 0.5f); + Color color46 = invincible ? invincibleColor : Color.BlueViolet; + + amount9 = 1f; + num157 = 0.5f; + scaleFactor9 = 10f; + num154 = 1; + + if (newPhasePhase) + { + float num161 = npc.ai[2] - (float)num150; + num161 /= (float)num151; + color36 *= num161; + color40 *= num161; + + if (flag9 || npc.ai[0] == 10f || startSecondAI) + { + color43 *= num161; + color44 *= num161; + } + + if (flag10 || npc.ai[0] == 17f) + { + color45 *= num161; + color46 *= num161; + } + } + + if (pauseAfterTeleportPhase) + { + float num162 = npc.ai[2]; + num162 /= 30f; + + if (num162 > 0.5f) + num162 = 1f - num162; + + num162 *= 2f; + num162 = 1f - num162; + color36 *= num162; + color40 *= num162; + color43 *= num162; + color44 *= num162; + color45 *= num162; + color46 *= num162; + } + + for (int num163 = 1; num163 < num153; num163 += num154) + { + Color color41 = color40; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (float)(num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + spriteBatch.Draw(texture, vector44, new Rectangle?(npc.frame), color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + if (flag9 || npc.ai[0] == 10f || startSecondAI) + { + Color color47 = color43; + color47 = Color.Lerp(color47, color44, amount9); + color47 *= (float)(num153 - num163) / 15f; + spriteBatch.Draw(texture2, vector44, new Rectangle?(npc.frame), color47, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + + if (flag10 || npc.ai[0] == 17f) + { + Color color48 = color45; + color48 = Color.Lerp(color48, color46, amount9); + color48 *= (float)(num153 - num163) / 15f; + spriteBatch.Draw(texture3, vector44, new Rectangle?(npc.frame), color48, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } + + for (int num164 = 1; num164 < num156; num164++) + { + Color color42 = color40; + color42 = Color.Lerp(color42, color36, amount9); + color42 = npc.GetAlpha(color42); + color42 *= 1f - num157; + Vector2 vector45 = npc.Center + ((float)num164 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; + vector45 -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector45 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + spriteBatch.Draw(texture, vector45, new Rectangle?(npc.frame), color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + if (flag9 || npc.ai[0] == 10f || startSecondAI) + { + Color color49 = color43; + color49 = Color.Lerp(color49, color44, amount9); + color49 = npc.GetAlpha(color49); + color49 *= 1f - num157; + spriteBatch.Draw(texture2, vector45, new Rectangle?(npc.frame), color49, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + + if (flag10 || npc.ai[0] == 17f) + { + Color color50 = color45; + color50 = Color.Lerp(color50, color46, amount9); + color50 = npc.GetAlpha(color50); + color50 *= 1f - num157; + spriteBatch.Draw(texture3, vector45, new Rectangle?(npc.frame), color50, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(texture, vector43, new Rectangle?(npc.frame), color40, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + if (flag9 || npc.ai[0] == 10f || startSecondAI) + spriteBatch.Draw(texture2, vector43, new Rectangle?(npc.frame), color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + if (flag10 || npc.ai[0] == 17f) + spriteBatch.Draw(texture3, vector43, new Rectangle?(npc.frame), color45, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + return false; } #endregion @@ -2915,45 +3090,50 @@ namespace CalamityMod.NPCs.Yharon #region FindFrame public override void FindFrame(int frameHeight) { - if ((!startSecondAI && (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f || npc.ai[0] == 21f)) || - (startSecondAI && (npc.ai[0] == 5f || npc.ai[0] < 2f))) //idle + bool idlePhases = (!startSecondAI && (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f || npc.ai[0] == 21f)) || (startSecondAI && (npc.ai[0] == 5f || npc.ai[0] < 2f)); + bool chargingOrSpawnPhases = (!startSecondAI && (npc.ai[0] == 1f || npc.ai[0] == 5f || npc.ai[0] == 7f || npc.ai[0] == 11f || npc.ai[0] == 14f || npc.ai[0] == 18f || npc.ai[0] == 22f)) || + (startSecondAI && (npc.ai[0] == 6f || npc.ai[0] == 2f || npc.ai[0] == 7f)); + bool projectileOrCirclePhases = (!startSecondAI && (npc.ai[0] == 2f || npc.ai[0] == 8f || npc.ai[0] == 12f || npc.ai[0] == 15f || npc.ai[0] == 19f || npc.ai[0] == 23f)) || + (startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 3f || npc.ai[0] == 8f)); + bool tornadoPhase = !startSecondAI && (npc.ai[0] == 3f || npc.ai[0] == 9f || npc.ai[0] == -1f || npc.ai[0] == 16f || npc.ai[0] == 20f); + bool newPhasePhase = (!startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 10f || npc.ai[0] == 17f || npc.ai[0] == 24f)) || (startSecondAI && npc.ai[0] == 9f); + + if (idlePhases) { int num84 = 5; - if (!startSecondAI && (npc.ai[0] == 6f || npc.ai[0] == 13f || npc.ai[0] == 21f)) //Phase ai switch + if (!startSecondAI && (npc.ai[0] == 6f || npc.ai[0] == 13f || npc.ai[0] == 21f)) { num84 = 4; } - npc.frameCounter += 1.0; + npc.frameCounter += 1D; if (npc.frameCounter > (double)num84) { - npc.frameCounter = 0.0; - npc.frame.Y = npc.frame.Y + frameHeight; + npc.frameCounter = 0D; + npc.frame.Y += frameHeight; } if (npc.frame.Y >= frameHeight * 5) { npc.frame.Y = 0; } } - if ((!startSecondAI && (npc.ai[0] == 1f || npc.ai[0] == 5f || npc.ai[0] == 7f || npc.ai[0] == 11f || npc.ai[0] == 14f || npc.ai[0] == 18f || npc.ai[0] == 22f)) || - (startSecondAI && (npc.ai[0] == 6f || npc.ai[0] == 2f || npc.ai[0] == 7f))) //Charging or birb spawn + if (chargingOrSpawnPhases) { npc.frame.Y = frameHeight * 5; } - if ((!startSecondAI && (npc.ai[0] == 2f || npc.ai[0] == 8f || npc.ai[0] == 12f || npc.ai[0] == 15f || npc.ai[0] == 19f || npc.ai[0] == 23f)) || - (startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 3f || npc.ai[0] == 8f))) //Fireball spit, teleport, circle, flamethrower + if (projectileOrCirclePhases) { npc.frame.Y = frameHeight * 5; } - if (!startSecondAI && (npc.ai[0] == 3f || npc.ai[0] == 9f || npc.ai[0] == -1f || npc.ai[0] == 16f || npc.ai[0] == 20f || npc.ai[0] == 24f)) //Summon tornadoes + if (tornadoPhase) { int num85 = 90; if (npc.ai[2] < (float)(num85 - 30) || npc.ai[2] > (float)(num85 - 10)) { - npc.frameCounter += 1.0; - if (npc.frameCounter > 5.0) + npc.frameCounter += 1D; + if (npc.frameCounter > 5D) { - npc.frameCounter = 0.0; - npc.frame.Y = npc.frame.Y + frameHeight; + npc.frameCounter = 0D; + npc.frame.Y += frameHeight; } if (npc.frame.Y >= frameHeight * 5) { @@ -2969,17 +3149,16 @@ namespace CalamityMod.NPCs.Yharon } } } - if ((!startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 10f || npc.ai[0] == 17f || npc.ai[0] == 25f)) || - (startSecondAI && npc.ai[0] == 9f)) //Enter new phase + if (newPhasePhase) { int num86 = 180; if (npc.ai[2] < (float)(num86 - 60) || npc.ai[2] > (float)(num86 - 20)) { - npc.frameCounter += 1.0; - if (npc.frameCounter > 5.0) + npc.frameCounter += 1D; + if (npc.frameCounter > 5D) { - npc.frameCounter = 0.0; - npc.frame.Y = npc.frame.Y + frameHeight; + npc.frameCounter = 0D; + npc.frame.Y += frameHeight; } if (npc.frame.Y >= frameHeight * 5) { diff --git a/NPCs/Yharon/YharonGlowGreen.png b/NPCs/Yharon/YharonGlowGreen.png new file mode 100644 index 0000000000..0328d39e94 Binary files /dev/null and b/NPCs/Yharon/YharonGlowGreen.png differ diff --git a/NPCs/Yharon/YharonGlowOrange.png b/NPCs/Yharon/YharonGlowOrange.png new file mode 100644 index 0000000000..0acc084ad8 Binary files /dev/null and b/NPCs/Yharon/YharonGlowOrange.png differ diff --git a/NPCs/Yharon/YharonGlowPurple.png b/NPCs/Yharon/YharonGlowPurple.png new file mode 100644 index 0000000000..7c34f8cc16 Binary files /dev/null and b/NPCs/Yharon/YharonGlowPurple.png differ diff --git a/Projectiles/Boss/BirbAura.cs b/Projectiles/Boss/BirbAura.cs index 7559e7c9a1..87dba79563 100644 --- a/Projectiles/Boss/BirbAura.cs +++ b/Projectiles/Boss/BirbAura.cs @@ -14,6 +14,7 @@ namespace CalamityMod.Projectiles.Boss public class BirbAura : ModProjectile { float timer = 0f; + float timeBeforeVanish = 0f; public override void SetStaticDefaults() { @@ -36,6 +37,7 @@ namespace CalamityMod.Projectiles.Boss writer.Write(projectile.localAI[0]); writer.Write(projectile.localAI[1]); writer.Write(timer); + writer.Write(timeBeforeVanish); } public override void ReceiveExtraAI(BinaryReader reader) @@ -43,6 +45,7 @@ namespace CalamityMod.Projectiles.Boss projectile.localAI[0] = reader.ReadSingle(); projectile.localAI[1] = reader.ReadSingle(); timer = reader.ReadSingle(); + timeBeforeVanish = reader.ReadSingle(); } public override void AI() @@ -62,15 +65,17 @@ namespace CalamityMod.Projectiles.Boss timer -= 1f; float num801 = 1f; + if (timeBeforeVanish == 0f) + timeBeforeVanish = projectile.timeLeft <= 900 ? 900f : 1200f; projectile.localAI[0] += 1f; - if (projectile.localAI[0] >= 1200f) + if (projectile.localAI[0] >= timeBeforeVanish) { projectile.Kill(); return; } - projectile.scale = (float)Math.Sin((double)(projectile.localAI[0] * Math.PI / 1200f)) * 10f * num801; + projectile.scale = (float)Math.Sin((double)(projectile.localAI[0] * Math.PI / timeBeforeVanish)) * 10f * num801; if (projectile.scale > num801) projectile.scale = num801; @@ -85,7 +90,7 @@ namespace CalamityMod.Projectiles.Boss if (vector78.HasValue) samplingPoint = vector78.Value; - float laserLength = MathHelper.Clamp(projectile.ai[1] - 160f, 1600f, 3600f); + float laserLength = projectile.ai[1] - 160f; float[] array3 = new float[(int)num805]; Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, laserLength, array3); float num807 = 0f; @@ -95,6 +100,8 @@ namespace CalamityMod.Projectiles.Boss } num807 /= num805; + num807 = MathHelper.Clamp(num807, 1800f, 3600f); + float amount = 0.5f; projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], num807, amount); @@ -104,7 +111,7 @@ namespace CalamityMod.Projectiles.Boss public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - if (timer <= 0f && projectile.localAI[0] >= 120f) + if (timer <= 0f && (projectile.localAI[0] >= 120f || projectile.timeLeft <= 900)) { if (projectile.owner == Main.myPlayer) { @@ -114,10 +121,9 @@ namespace CalamityMod.Projectiles.Boss Vector2 ai0 = target.Center - fireFrom; float ai = (float)Main.rand.Next(100); Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, ai0.ToRotation(), ai); + Projectile.NewProjectile(fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, 0f, projectile.owner, ai0.ToRotation(), ai); } } - damage = 0; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -177,7 +183,7 @@ namespace CalamityMod.Projectiles.Boss return true; } float num6 = 0f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 22f * projectile.scale, ref num6)) + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 80f * projectile.scale, ref num6)) { return true; } diff --git a/Projectiles/Boss/BirbAuraFlare.cs b/Projectiles/Boss/BirbAuraFlare.cs index ef9a5e85bd..214d7795c2 100644 --- a/Projectiles/Boss/BirbAuraFlare.cs +++ b/Projectiles/Boss/BirbAuraFlare.cs @@ -29,12 +29,14 @@ namespace CalamityMod.Projectiles.Boss public override void SendExtraAI(BinaryWriter writer) { writer.Write(projectile.localAI[0]); - } + writer.Write(projectile.localAI[1]); + } public override void ReceiveExtraAI(BinaryReader reader) { projectile.localAI[0] = reader.ReadSingle(); - } + projectile.localAI[1] = reader.ReadSingle(); + } public override void AI() { @@ -47,11 +49,11 @@ namespace CalamityMod.Projectiles.Boss if (projectile.localAI[0] > 10f) { // Dust pulse effect - projectile.ai[0] = (float)Math.Abs(Math.Cos((double)MathHelper.ToRadians(projectile.localAI[0] * 2f))); + projectile.localAI[1] = (float)Math.Abs(Math.Cos((double)MathHelper.ToRadians(projectile.localAI[0] * 2f))); int num626 = 18; for (int num627 = 0; num627 < num626; num627++) { - Vector2 vector45 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * projectile.ai[0]; + Vector2 vector45 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * projectile.localAI[1]; vector45 = vector45.RotatedBy((double)(num627 - (num626 / 2 - 1)) * 3.1415926535897931 / (double)(float)num626, default) + projectile.Center; Vector2 value15 = ((float)(Main.rand.NextDouble() * Math.PI) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); int num628 = Dust.NewDust(vector45 + value15, 0, 0, 60, value15.X * 2f, value15.Y * 2f, 100, default, 1f); @@ -65,7 +67,8 @@ namespace CalamityMod.Projectiles.Boss Vector2 value16 = Main.player[num625].Center - projectile.Center; float num629 = 4f; - num629 += projectile.localAI[0] / 60f; + float divisor = projectile.ai[0] == 1f ? 45f : 60f; + num629 += projectile.localAI[0] / divisor; projectile.velocity = Vector2.Normalize(value16) * num629; if (value16.Length() < 32f) { @@ -111,23 +114,40 @@ namespace CalamityMod.Projectiles.Boss { num231 = Main.maxTilesY - num233 - 10; } - int spawnAreaY = Main.maxTilesY - num231; - for (int num234 = num231; num234 < num231 + spawnAreaY; num234++) - { - Tile tile = Main.tile[num232, num234]; - if (tile.active() && !TileID.Sets.Platforms[tile.type] && (Main.tileSolid[(int)tile.type] || tile.liquid != 0)) - { - num231 = num234; - break; - } - } float x = (float)(num232 * 16); - float y = (float)(num231 * 16 - 48); + float y = (float)(num231 * 16 + 900); Vector2 laserVelocity = new Vector2(x, 160f) - new Vector2(x, y); - laserVelocity.Normalize(); int damage = Main.expertMode ? 75 : 100; - int num236 = Projectile.NewProjectile(x, y, 0f, laserVelocity.Y, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, x, y); - Main.projectile[num236].netUpdate = true; + if (projectile.ai[0] == 1f) + { + x += 500f; + if ((int)(x / 16f) > Main.maxTilesX - 10) + { + x = (float)(Main.maxTilesX - 10) * 16f; + } + laserVelocity = new Vector2(x, 160f) - new Vector2(x, y); + laserVelocity.Normalize(); + int num237 = Projectile.NewProjectile(x, y, 0f, laserVelocity.Y, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, x, y); + Main.projectile[num237].timeLeft = 900; + Main.projectile[num237].netUpdate = true; + + x -= 1000f; + if ((int)(x / 16f) < 10) + { + x = 160f; + } + laserVelocity = new Vector2(x, 160f) - new Vector2(x, y); + laserVelocity.Normalize(); + int num238 = Projectile.NewProjectile(x, y, 0f, laserVelocity.Y, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, x, y); + Main.projectile[num238].timeLeft = 900; + Main.projectile[num238].netUpdate = true; + } + else + { + laserVelocity.Normalize(); + int num236 = Projectile.NewProjectile(x, y, 0f, laserVelocity.Y, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, x, y); + Main.projectile[num236].netUpdate = true; + } } } } diff --git a/Projectiles/Boss/OldDukeGore.cs b/Projectiles/Boss/OldDukeGore.cs index 112b508d50..1c91e308a0 100644 --- a/Projectiles/Boss/OldDukeGore.cs +++ b/Projectiles/Boss/OldDukeGore.cs @@ -28,6 +28,7 @@ namespace CalamityMod.Projectiles.Boss projectile.penetrate = 1; projectile.timeLeft = 300; projectile.alpha = 255; + cooldownSlot = 1; } public override void AI() @@ -93,7 +94,12 @@ namespace CalamityMod.Projectiles.Boss target.AddBuff(ModContent.BuffType(), 180); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); return false; diff --git a/Projectiles/Boss/OldDukeVortex.cs b/Projectiles/Boss/OldDukeVortex.cs index a0c7bcae8d..88ec64b01d 100644 --- a/Projectiles/Boss/OldDukeVortex.cs +++ b/Projectiles/Boss/OldDukeVortex.cs @@ -30,7 +30,8 @@ namespace CalamityMod.Projectiles.Boss projectile.tileCollide = false; projectile.ignoreWater = true; projectile.timeLeft = 1800; - } + cooldownSlot = 1; + } public override void AI() { @@ -94,6 +95,7 @@ namespace CalamityMod.Projectiles.Boss } float distanceRequired = 800f * projectile.scale; + float succPower = 0.4f; for (int i = 0; i < Main.maxPlayers; i++) { Player player = Main.player[i]; @@ -106,35 +108,18 @@ namespace CalamityMod.Projectiles.Boss float wingTimeSet = (float)Math.Ceiling((float)player.wingTimeMax * 0.5f * distanceRatio); if (player.wingTime > wingTimeSet) - { player.wingTime = wingTimeSet; - } - float succPower = 0.4f; float multiplier = 1f - distanceRatio; if (player.Center.X < projectile.Center.X) - { player.velocity.X += succPower * multiplier; - } else - { player.velocity.X -= succPower * multiplier; - } - int num = (int)player.Center.X / 16; - int num2 = (int)(player.position.Y + (float)player.height - 1f) / 16; - Tile tile = Framing.GetTileSafely(num, num2 + 1); - if (!WorldGen.SolidTile2(tile) || !player.controlJump) - { - if (player.Center.Y < projectile.Center.Y) - { - player.velocity.Y += succPower * multiplier; - } - else - { - player.velocity.Y -= succPower * multiplier; - } - } + if (player.Center.Y < projectile.Center.Y) + player.velocity.Y += succPower * multiplier; + else + player.velocity.Y -= succPower * multiplier; } } } @@ -178,5 +163,10 @@ namespace CalamityMod.Projectiles.Boss { target.AddBuff(ModContent.BuffType(), 600); } - } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/RedLightning.cs b/Projectiles/Boss/RedLightning.cs index 9e6f2d3a1c..aef7436204 100644 --- a/Projectiles/Boss/RedLightning.cs +++ b/Projectiles/Boss/RedLightning.cs @@ -33,7 +33,8 @@ namespace CalamityMod.Projectiles.Boss projectile.tileCollide = false; projectile.extraUpdates = 20; projectile.timeLeft = 1260; - } + cooldownSlot = 1; + } public override void SendExtraAI(BinaryWriter writer) { @@ -171,6 +172,11 @@ namespace CalamityMod.Projectiles.Boss } } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Vector2 end = projectile.position + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; diff --git a/Projectiles/Magic/EelDrop.cs b/Projectiles/Magic/EelDrop.cs index 10204fde15..e6609a9a17 100644 --- a/Projectiles/Magic/EelDrop.cs +++ b/Projectiles/Magic/EelDrop.cs @@ -3,6 +3,7 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Buffs.StatDebuffs; namespace CalamityMod.Projectiles.Magic { @@ -46,9 +47,16 @@ namespace CalamityMod.Projectiles.Magic return true; } - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(BuffID.Venom, 120); + target.AddBuff(BuffID.Venom, 60); + target.AddBuff(ModContent.BuffType(), 60); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.Venom, 60); + target.AddBuff(ModContent.BuffType(), 60); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Magic/HellfireExplosionFriendly.cs b/Projectiles/Magic/HellfireExplosionFriendly.cs index c59d30f062..415ef0e59a 100644 --- a/Projectiles/Magic/HellfireExplosionFriendly.cs +++ b/Projectiles/Magic/HellfireExplosionFriendly.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Magic projectile.tileCollide = false; projectile.penetrate = -1; projectile.timeLeft = 180; - projectile.magic = true; + projectile.magic = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } diff --git a/Projectiles/Magic/SlitheringEelProjectile.cs b/Projectiles/Magic/SlitheringEelProjectile.cs index 0b4dea61a1..59bc79e249 100644 --- a/Projectiles/Magic/SlitheringEelProjectile.cs +++ b/Projectiles/Magic/SlitheringEelProjectile.cs @@ -5,6 +5,7 @@ using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Buffs.StatDebuffs; namespace CalamityMod.Projectiles.Magic { @@ -20,7 +21,7 @@ namespace CalamityMod.Projectiles.Magic public override void SetDefaults() { - projectile.width = 94; + projectile.width = 22; projectile.height = 22; projectile.friendly = true; projectile.magic = true; @@ -67,10 +68,21 @@ namespace CalamityMod.Projectiles.Magic CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, new Color(255, 255, 255, 127), ProjectileID.Sets.TrailingMode[projectile.type], 1); return false; } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { projectile.ai[0]++; + target.AddBuff(BuffID.Venom, 180); + target.AddBuff(ModContent.BuffType(), 180); } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + projectile.ai[0]++; + target.AddBuff(BuffID.Venom, 180); + target.AddBuff(ModContent.BuffType(), 180); + } + public override void Kill(int timeLeft) { for (int dust = 0; dust <= 22; dust++) diff --git a/Projectiles/Ranged/BigCoral.cs b/Projectiles/Ranged/BigCoral.cs index ba41d38517..112a2018f9 100644 --- a/Projectiles/Ranged/BigCoral.cs +++ b/Projectiles/Ranged/BigCoral.cs @@ -48,5 +48,10 @@ namespace CalamityMod.Projectiles.Ranged { target.AddBuff(ModContent.BuffType(), 15); } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 15); + } } } diff --git a/Projectiles/Rogue/InkBombProjectile.cs b/Projectiles/Rogue/InkBombProjectile.cs index 3b56062815..e6822b154a 100644 --- a/Projectiles/Rogue/InkBombProjectile.cs +++ b/Projectiles/Rogue/InkBombProjectile.cs @@ -51,7 +51,8 @@ namespace CalamityMod.Projectiles.Rogue private void CreateInk() { - Main.PlaySound(2, (int)Main.player[projectile.owner].position.X, (int)Main.player[projectile.owner].position.Y, 14); + Player player = Main.player[projectile.owner]; + Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 14); for (int i = 0; i < 20; i++) { int projType = Main.rand.Next(0, 3); @@ -68,7 +69,7 @@ namespace CalamityMod.Projectiles.Rogue inkType = ModContent.ProjectileType(); break; } - int inkID = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 2f), inkType, 22, 7, projectile.owner); + int inkID = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 2f), inkType, (int)(22 * player.RogueDamage()), 7, projectile.owner); Main.projectile[inkID].timeLeft += Main.rand.Next(-20, 25); } projectile.Kill(); diff --git a/Projectiles/Rogue/PartisanExplosion.cs b/Projectiles/Rogue/PartisanExplosion.cs index 051b40897f..fb25ff52a8 100644 --- a/Projectiles/Rogue/PartisanExplosion.cs +++ b/Projectiles/Rogue/PartisanExplosion.cs @@ -6,7 +6,6 @@ using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Rogue { - //TODO -- Make the dust from the explosion not look like ass, reduce timeleft if neccesary public class PartisanExplosion : ModProjectile { public override void SetStaticDefaults() diff --git a/Projectiles/Magic/BrimstoneHellfireballFriendly2.cs b/Projectiles/Typeless/BrimstoneHellfireballFriendly2.cs similarity index 94% rename from Projectiles/Magic/BrimstoneHellfireballFriendly2.cs rename to Projectiles/Typeless/BrimstoneHellfireballFriendly2.cs index b80efb3817..e93d34d612 100644 --- a/Projectiles/Magic/BrimstoneHellfireballFriendly2.cs +++ b/Projectiles/Typeless/BrimstoneHellfireballFriendly2.cs @@ -3,7 +3,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic +namespace CalamityMod.Projectiles.Typeless { public class BrimstoneHellfireballFriendly2 : ModProjectile { @@ -18,9 +18,9 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 12; projectile.friendly = true; projectile.ignoreWater = true; - projectile.timeLeft = 600; + projectile.tileCollide = false; + projectile.timeLeft = 50; projectile.penetrate = -1; - projectile.magic = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } diff --git a/Projectiles/Magic/BrimstoneHellfireballFriendly2.png b/Projectiles/Typeless/BrimstoneHellfireballFriendly2.png similarity index 100% rename from Projectiles/Magic/BrimstoneHellfireballFriendly2.png rename to Projectiles/Typeless/BrimstoneHellfireballFriendly2.png diff --git a/Projectiles/Summon/DemonshadeRedDevil.cs b/Projectiles/Typeless/DemonshadeRedDevil.cs similarity index 93% rename from Projectiles/Summon/DemonshadeRedDevil.cs rename to Projectiles/Typeless/DemonshadeRedDevil.cs index 0a6c4c998f..4ca4b58c96 100644 --- a/Projectiles/Summon/DemonshadeRedDevil.cs +++ b/Projectiles/Typeless/DemonshadeRedDevil.cs @@ -7,7 +7,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Summon +namespace CalamityMod.Projectiles.Typeless { public class DemonshadeRedDevil : ModProjectile { @@ -27,7 +27,6 @@ namespace CalamityMod.Projectiles.Summon projectile.height = 48; projectile.netImportant = true; projectile.friendly = true; - projectile.minion = true; projectile.ignoreWater = true; projectile.timeLeft = 18000; projectile.penetrate = -1; @@ -57,6 +56,11 @@ namespace CalamityMod.Projectiles.Summon } } dust--; + if (dust == 2) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = player.AverageDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + } if (dust >= 0) { int num501 = 50; @@ -67,6 +71,13 @@ namespace CalamityMod.Projectiles.Summon Main.dust[num503].scale *= 1.15f; } } + if (player.AverageDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / + projectile.Calamity().spawnedPlayerMinionDamageValue * + player.AverageDamage()); + projectile.damage = damage2; + } projectile.frameCounter++; if (projectile.frameCounter > 8) { @@ -231,8 +242,8 @@ namespace CalamityMod.Projectiles.Summon } if (num651 > 2000f) { - projectile.position.X = Main.player[projectile.owner].Center.X - (float)(projectile.width / 2); - projectile.position.Y = Main.player[projectile.owner].Center.Y - (float)(projectile.height / 2); + projectile.position.X = player.Center.X - (float)(projectile.width / 2); + projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); projectile.netUpdate = true; } if (num651 > 70f) diff --git a/Projectiles/Summon/DemonshadeRedDevil.png b/Projectiles/Typeless/DemonshadeRedDevil.png similarity index 100% rename from Projectiles/Summon/DemonshadeRedDevil.png rename to Projectiles/Typeless/DemonshadeRedDevil.png diff --git a/Projectiles/Summon/GladiatorSword.cs b/Projectiles/Typeless/GladiatorSword.cs similarity index 80% rename from Projectiles/Summon/GladiatorSword.cs rename to Projectiles/Typeless/GladiatorSword.cs index 1597094168..637f68d012 100644 --- a/Projectiles/Summon/GladiatorSword.cs +++ b/Projectiles/Typeless/GladiatorSword.cs @@ -1,10 +1,11 @@ using CalamityMod.CalPlayer; +using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Summon +namespace CalamityMod.Projectiles.Typeless { public class GladiatorSword : ModProjectile { @@ -21,14 +22,17 @@ namespace CalamityMod.Projectiles.Summon projectile.width = 22; projectile.height = 22; projectile.ignoreWater = true; - projectile.minionSlots = 0f; projectile.timeLeft = 18000; projectile.tileCollide = false; projectile.friendly = true; projectile.timeLeft *= 5; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; + projectile.localNPCHitCooldown = 10 - + (Main.hardMode ? 2 : 0) - + (NPC.downedPlantBoss ? 2 : 0) - + (NPC.downedMoonlord ? 2 : 0) - + (CalamityWorld.downedDoG ? 2 : 0); } public override void AI() @@ -38,15 +42,15 @@ namespace CalamityMod.Projectiles.Summon CalamityPlayer modPlayer = player.Calamity(); if (projectile.localAI[0] == 0f) { - projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionDamageValue = player.AverageDamage(); projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; projectile.localAI[0] += 1f; } - if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + if (player.AverageDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / projectile.Calamity().spawnedPlayerMinionDamageValue * - player.MinionDamage()); + player.AverageDamage()); projectile.damage = damage2; } if (!modPlayer.gladiatorSword) @@ -69,7 +73,8 @@ namespace CalamityMod.Projectiles.Summon Vector2 vector = player.Center - projectile.Center; projectile.rotation = vector.ToRotation() - 1.57f; projectile.Center = player.Center + new Vector2(80, 0).RotatedBy(rotation); - rotation += 0.03; + double rotateAmt = CalamityWorld.downedDoG ? 0.1 : NPC.downedMoonlord ? 0.08 : NPC.downedPlantBoss ? 0.05 : Main.hardMode ? 0.04 : 0.03; + rotation += rotateAmt; if (rotation >= 360) { rotation = 0; diff --git a/Projectiles/Summon/GladiatorSword.png b/Projectiles/Typeless/GladiatorSword.png similarity index 100% rename from Projectiles/Summon/GladiatorSword.png rename to Projectiles/Typeless/GladiatorSword.png diff --git a/Projectiles/Summon/GladiatorSword2.cs b/Projectiles/Typeless/GladiatorSword2.cs similarity index 76% rename from Projectiles/Summon/GladiatorSword2.cs rename to Projectiles/Typeless/GladiatorSword2.cs index 39d78ca95c..20bd343449 100644 --- a/Projectiles/Summon/GladiatorSword2.cs +++ b/Projectiles/Typeless/GladiatorSword2.cs @@ -1,10 +1,11 @@ using CalamityMod.CalPlayer; +using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Summon +namespace CalamityMod.Projectiles.Typeless { public class GladiatorSword2 : ModProjectile { @@ -21,14 +22,17 @@ namespace CalamityMod.Projectiles.Summon projectile.width = 22; projectile.height = 22; projectile.ignoreWater = true; - projectile.minionSlots = 0f; projectile.timeLeft = 18000; projectile.tileCollide = false; projectile.friendly = true; projectile.timeLeft *= 5; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; + projectile.localNPCHitCooldown = 10 - + (Main.hardMode ? 2 : 0) - + (NPC.downedPlantBoss ? 2 : 0) - + (NPC.downedMoonlord ? 2 : 0) - + (CalamityWorld.downedDoG ? 2 : 0); } public override void AI() @@ -38,15 +42,15 @@ namespace CalamityMod.Projectiles.Summon CalamityPlayer modPlayer = player.Calamity(); if (projectile.localAI[0] == 0f) { - projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionDamageValue = player.AverageDamage(); projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; projectile.localAI[0] += 1f; } - if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + if (player.AverageDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / projectile.Calamity().spawnedPlayerMinionDamageValue * - player.MinionDamage()); + player.AverageDamage()); projectile.damage = damage2; } if (!modPlayer.gladiatorSword) @@ -69,7 +73,9 @@ namespace CalamityMod.Projectiles.Summon Vector2 vector = player.Center - projectile.Center; projectile.rotation = vector.ToRotation() - 1.57f; projectile.Center = player.Center + new Vector2(80, 0).RotatedBy(rotation); - rotation -= 0.03; + double rotateAmt = CalamityWorld.downedDoG ? 0.09 : NPC.downedMoonlord ? 0.07 : NPC.downedPlantBoss ? 0.04 : Main.hardMode ? 0.03 : 0.02; + //values are slightly different from the other sword to make this sword marginally slower so the intersection point isn't always at the same spot + rotation -= rotateAmt; if (rotation <= 0) { rotation = 360; diff --git a/Projectiles/Summon/GladiatorSword2.png b/Projectiles/Typeless/GladiatorSword2.png similarity index 100% rename from Projectiles/Summon/GladiatorSword2.png rename to Projectiles/Typeless/GladiatorSword2.png diff --git a/Projectiles/Magic/HellfireExplosionFriendly2.cs b/Projectiles/Typeless/HellfireExplosionFriendly2.cs similarity index 97% rename from Projectiles/Magic/HellfireExplosionFriendly2.cs rename to Projectiles/Typeless/HellfireExplosionFriendly2.cs index e5b7deb2ae..b5c0d52d8d 100644 --- a/Projectiles/Magic/HellfireExplosionFriendly2.cs +++ b/Projectiles/Typeless/HellfireExplosionFriendly2.cs @@ -4,7 +4,7 @@ using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic +namespace CalamityMod.Projectiles.Typeless { public class HellfireExplosionFriendly2 : ModProjectile { @@ -22,7 +22,6 @@ namespace CalamityMod.Projectiles.Magic projectile.tileCollide = false; projectile.penetrate = -1; projectile.timeLeft = 300; - projectile.magic = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } diff --git a/Projectiles/Magic/HellfireExplosionFriendly2.png b/Projectiles/Typeless/HellfireExplosionFriendly2.png similarity index 100% rename from Projectiles/Magic/HellfireExplosionFriendly2.png rename to Projectiles/Typeless/HellfireExplosionFriendly2.png diff --git a/Projectiles/Magic/PendantProjectile1.cs b/Projectiles/Typeless/PendantProjectile1.cs similarity index 63% rename from Projectiles/Magic/PendantProjectile1.cs rename to Projectiles/Typeless/PendantProjectile1.cs index b7e94c97b4..6898d48be8 100644 --- a/Projectiles/Magic/PendantProjectile1.cs +++ b/Projectiles/Typeless/PendantProjectile1.cs @@ -1,7 +1,8 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic +using CalamityMod.Buffs.StatDebuffs; +namespace CalamityMod.Projectiles.Typeless { public class PendantProjectile1 : ModProjectile { @@ -13,17 +14,17 @@ namespace CalamityMod.Projectiles.Magic public override void SetDefaults() { projectile.width = 10; - projectile.height = 16; + projectile.height = 10; projectile.friendly = true; projectile.ignoreWater = true; - projectile.timeLeft = 600; + projectile.timeLeft = 220; projectile.penetrate = 1; - projectile.magic = true; + projectile.tileCollide = false; } public override void AI() { - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.35f / 255f, (255 - projectile.alpha) * 0.35f / 255f); + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.2f / 255f, (255 - projectile.alpha) * 0.2f / 255f); projectile.rotation += projectile.velocity.X * 1.25f; for (int num457 = 0; num457 < 5; num457++) { @@ -33,5 +34,15 @@ namespace CalamityMod.Projectiles.Magic Main.dust[num458].velocity += projectile.velocity * 0.1f; } } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 15); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 15); + } } } diff --git a/Projectiles/Magic/PendantProjectile1.png b/Projectiles/Typeless/PendantProjectile1.png similarity index 100% rename from Projectiles/Magic/PendantProjectile1.png rename to Projectiles/Typeless/PendantProjectile1.png diff --git a/Projectiles/Magic/PendantProjectile2.cs b/Projectiles/Typeless/PendantProjectile2.cs similarity index 63% rename from Projectiles/Magic/PendantProjectile2.cs rename to Projectiles/Typeless/PendantProjectile2.cs index 43d9c5b3ee..278eff68a7 100644 --- a/Projectiles/Magic/PendantProjectile2.cs +++ b/Projectiles/Typeless/PendantProjectile2.cs @@ -1,7 +1,8 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic +using CalamityMod.Buffs.StatDebuffs; +namespace CalamityMod.Projectiles.Typeless { public class PendantProjectile2 : ModProjectile { @@ -13,17 +14,17 @@ namespace CalamityMod.Projectiles.Magic public override void SetDefaults() { projectile.width = 10; - projectile.height = 16; + projectile.height = 10; projectile.friendly = true; projectile.ignoreWater = true; - projectile.timeLeft = 600; + projectile.timeLeft = 220; projectile.penetrate = 1; - projectile.magic = true; + projectile.tileCollide = false; } public override void AI() { - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.35f / 255f, (255 - projectile.alpha) * 0.35f / 255f); + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.2f / 255f, (255 - projectile.alpha) * 0.2f / 255f); projectile.rotation += projectile.velocity.X * 1.25f; for (int num457 = 0; num457 < 5; num457++) { @@ -33,5 +34,15 @@ namespace CalamityMod.Projectiles.Magic Main.dust[num458].velocity += projectile.velocity * 0.1f; } } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 15); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 15); + } } } diff --git a/Projectiles/Magic/PendantProjectile2.png b/Projectiles/Typeless/PendantProjectile2.png similarity index 100% rename from Projectiles/Magic/PendantProjectile2.png rename to Projectiles/Typeless/PendantProjectile2.png diff --git a/Projectiles/Magic/PendantProjectile3.cs b/Projectiles/Typeless/PendantProjectile3.cs similarity index 60% rename from Projectiles/Magic/PendantProjectile3.cs rename to Projectiles/Typeless/PendantProjectile3.cs index ed1fea6bd2..c9e8e042bb 100644 --- a/Projectiles/Magic/PendantProjectile3.cs +++ b/Projectiles/Typeless/PendantProjectile3.cs @@ -1,7 +1,8 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic +using CalamityMod.Buffs.StatDebuffs; +namespace CalamityMod.Projectiles.Typeless { public class PendantProjectile3 : ModProjectile { @@ -13,17 +14,19 @@ namespace CalamityMod.Projectiles.Magic public override void SetDefaults() { projectile.width = 14; - projectile.height = 26; + projectile.height = 14; projectile.friendly = true; projectile.ignoreWater = true; - projectile.timeLeft = 600; + projectile.timeLeft = 220; projectile.penetrate = 1; - projectile.magic = true; + projectile.tileCollide = false; } public override void AI() { - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.35f / 255f, (255 - projectile.alpha) * 0.35f / 255f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 400f, 10f, 20f); + + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.2f / 255f, (255 - projectile.alpha) * 0.2f / 255f); projectile.rotation += projectile.velocity.X * 1.25f; for (int num457 = 0; num457 < 5; num457++) { @@ -33,5 +36,15 @@ namespace CalamityMod.Projectiles.Magic Main.dust[num458].velocity += projectile.velocity * 0.1f; } } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 30); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 30); + } } } diff --git a/Projectiles/Magic/PendantProjectile3.png b/Projectiles/Typeless/PendantProjectile3.png similarity index 100% rename from Projectiles/Magic/PendantProjectile3.png rename to Projectiles/Typeless/PendantProjectile3.png diff --git a/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index 4f4c51476d..781426b6ab 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -63,6 +63,7 @@ namespace CalamityMod public static float MinionDamage(this Player player) => player.allDamage + player.minionDamage - 1f; public static float ThrownDamage(this Player player) => player.allDamage + player.thrownDamage - 1f; public static float RogueDamage(this Player player) => player.allDamage + player.thrownDamage + player.Calamity().throwingDamage - 2f; + public static float AverageDamage(this Player player) => player.allDamage + (player.meleeDamage + player.rangedDamage + player.magicDamage + player.minionDamage + player.Calamity().throwingDamage - 5f) / 5f; public static bool IsUnderwater(this Player player) => Collision.DrownCollision(player.position, player.width, player.height, player.gravDir); public static bool InSpace(this Player player)