diff --git a/Buffs/CalamityGlobalBuff.cs b/Buffs/CalamityGlobalBuff.cs index 5a3d336517..d8d9834430 100644 --- a/Buffs/CalamityGlobalBuff.cs +++ b/Buffs/CalamityGlobalBuff.cs @@ -26,14 +26,6 @@ namespace CalamityMod.Buffs { player.lavaMax += 420; } - else if (type == BuffID.Rage) - { - player.Calamity().throwingCrit += 10; - } - else if (type == BuffID.WellFed) - { - player.Calamity().throwingCrit += 2; - } else if (type >= BuffID.NebulaUpDmg1 && type <= BuffID.NebulaUpDmg3) { float nebulaDamage = 0.075f * (float)player.nebulaLevelDamage; //7.5% to 22.5% diff --git a/Buffs/Cooldowns/EnergyShellCooldown.cs b/Buffs/Cooldowns/EnergyShellCooldown.cs new file mode 100644 index 0000000000..696b9883bf --- /dev/null +++ b/Buffs/Cooldowns/EnergyShellCooldown.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Cooldowns +{ + public class EnergyShellCooldown : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Energy Shell Cooldown"); + Description.SetDefault("Your energy shell is recharging"); + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + longerExpertDebuff = false; + canBeCleared = false; + } + + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().energyShellCooldown = true; + } + } +} diff --git a/Buffs/Cooldowns/EnergyShellCooldown.png b/Buffs/Cooldowns/EnergyShellCooldown.png new file mode 100644 index 0000000000..129de0c085 Binary files /dev/null and b/Buffs/Cooldowns/EnergyShellCooldown.png differ diff --git a/Buffs/Placeables/ChaosCandleBuff.png b/Buffs/Placeables/ChaosCandleBuff.png index f5271e8717..eb9db97d85 100644 Binary files a/Buffs/Placeables/ChaosCandleBuff.png and b/Buffs/Placeables/ChaosCandleBuff.png differ diff --git a/Buffs/Placeables/TranquilityCandleBuff.png b/Buffs/Placeables/TranquilityCandleBuff.png index 2cf02e775e..668c2f67bd 100644 Binary files a/Buffs/Placeables/TranquilityCandleBuff.png and b/Buffs/Placeables/TranquilityCandleBuff.png differ diff --git a/Buffs/StatDebuffs/ProfanedWeakness.cs b/Buffs/StatDebuffs/ProfanedWeakness.cs new file mode 100644 index 0000000000..6b75ba3d2e --- /dev/null +++ b/Buffs/StatDebuffs/ProfanedWeakness.cs @@ -0,0 +1,18 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.StatDebuffs +{ + public class ProfanedWeakness : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Profaned Weakness"); + Description.SetDefault("You do less damage"); + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + longerExpertDebuff = false; + } + } +} diff --git a/Buffs/StatDebuffs/ProfanedWeakness.png b/Buffs/StatDebuffs/ProfanedWeakness.png new file mode 100644 index 0000000000..eec27cfaac Binary files /dev/null and b/Buffs/StatDebuffs/ProfanedWeakness.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 5f024380cf..8d0531c549 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -35,6 +35,7 @@ using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; using CalamityMod.Projectiles.Environment; +using CalamityMod.Tiles; using CalamityMod.UI; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -42,6 +43,7 @@ using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; using System.IO; +using System.Linq; using Terraria; using Terraria.DataStructures; using Terraria.GameInput; @@ -185,6 +187,7 @@ namespace CalamityMod.CalPlayer public float shieldInvinc = 5f; public GaelSwitchPhase gaelSwitchTimer = 0; public int galileoCooldown = 0; + public int soundCooldown = 0; public int planarSpeedBoost = 0; public int profanedSoulWeaponUsage = 0; public int profanedSoulWeaponType = 0; @@ -231,7 +234,7 @@ namespace CalamityMod.CalPlayer public float throwingDamage = 1f; public float throwingVelocity = 1f; - public int throwingCrit = 4; + public int throwingCrit = 0; public bool throwingAmmoCost75 = false; public bool throwingAmmoCost66 = false; public bool throwingAmmoCost50 = false; @@ -410,6 +413,7 @@ namespace CalamityMod.CalPlayer public bool pAmulet = false; public bool fBarrier = false; public bool aBrain = false; + public bool amalgam = false; public bool lol = false; public bool raiderTalisman = false; public int raiderStack = 0; @@ -533,6 +537,7 @@ namespace CalamityMod.CalPlayer public bool snowRuffianSet = false; public bool forbiddenCirclet = false; public int forbiddenCooldown = 0; + public int tornadoCooldown = 0; public bool eskimoSet = false; //vanilla armor public bool meteorSet = false; //vanilla armor, for space gun nerf public bool victideSet = false; @@ -676,6 +681,7 @@ namespace CalamityMod.CalPlayer public bool iCantBreathe = false; //Frozen Lungs debuff public bool cragsLava = false; public bool vaporfied = false; + public bool energyShellCooldown = false; #endregion #region Buff @@ -1252,7 +1258,7 @@ namespace CalamityMod.CalPlayer throwingDamage = 1f; throwingVelocity = 1f; - throwingCrit = 4; + throwingCrit = 0; throwingAmmoCost75 = false; throwingAmmoCost66 = false; throwingAmmoCost50 = false; @@ -1426,6 +1432,7 @@ namespace CalamityMod.CalPlayer pAmulet = false; fBarrier = false; aBrain = false; + amalgam = false; frostFlare = false; beeResist = false; uberBees = false; @@ -1637,6 +1644,7 @@ namespace CalamityMod.CalPlayer iCantBreathe = false; cragsLava = false; vaporfied = false; + energyShellCooldown = false; revivify = false; trinketOfChiBuff = false; @@ -1847,6 +1855,7 @@ namespace CalamityMod.CalPlayer andromedaState = AndromedaPlayerState.Inactive; planarSpeedBoost = 0; galileoCooldown = 0; + soundCooldown = 0; rage = 0; adrenaline = 0; raiderStack = 0; @@ -1881,6 +1890,7 @@ namespace CalamityMod.CalPlayer doubledHorror = false; sulphurBubbleCooldown = 0; forbiddenCooldown = 0; + tornadoCooldown = 0; ladHearts = 0; alcoholPoisoning = false; @@ -1927,6 +1937,7 @@ namespace CalamityMod.CalPlayer iCantBreathe = false; cragsLava = false; vaporfied = false; + energyShellCooldown = false; #endregion #region Rogue @@ -1937,7 +1948,7 @@ namespace CalamityMod.CalPlayer throwingDamage = 1f; throwingVelocity = 1f; - throwingCrit = 4; + throwingCrit = 0; throwingAmmoCost75 = false; throwingAmmoCost66 = false; throwingAmmoCost50 = false; @@ -2282,6 +2293,24 @@ namespace CalamityMod.CalPlayer (double)point.Y > (Main.rockLayer + y * 0.26); ZoneSulphur = (CalamityWorld.sulphurTiles > 30 || (player.ZoneOverworldHeight && sulphurPosX)) && !ZoneAbyss; + + Mod fargos = ModLoader.GetMod("Fargowiltas"); + if (fargos != null) + { + //Fargo's fountain effects + if (Main.fountainColor == CalamityGlobalTile.WaterStyles.FirstOrDefault((style) => style.Name == "SunkenSeaWater").Type) + { + ZoneSunkenSea = true; + } + if (Main.fountainColor == CalamityGlobalTile.WaterStyles.FirstOrDefault((style) => style.Name == "SulphuricWater").Type) + { + ZoneSulphur = true; + } + if (Main.fountainColor == CalamityGlobalTile.WaterStyles.FirstOrDefault((style) => style.Name == "AstralWater").Type) + { + ZoneAstral = true; + } + } } public override bool CustomBiomesMatch(Player other) @@ -2375,8 +2404,6 @@ namespace CalamityMod.CalPlayer if (!mediumcoreDeath) { - if (player.name == "Aleksh" || player.name == "Shark Lad") - items.Add(createItem(ModContent.ItemType())); items.Add(createItem(ModContent.ItemType())); items.Add(createItem(ModContent.ItemType())); items.Add(createItem(ModContent.ItemType())); @@ -2656,8 +2683,9 @@ namespace CalamityMod.CalPlayer } if (plagueReaper && plagueReaperCooldown <= 0) plagueReaperCooldown = 1800; - if (forbiddenCirclet) + if (forbiddenCirclet && forbiddenCooldown <= 0) { + forbiddenCooldown = 20; int stormMana = (int)(ForbiddenCirclet.manaCost * player.manaCost); if (player.statMana < stormMana) { @@ -2713,7 +2741,7 @@ namespace CalamityMod.CalPlayer } if (CalamityMod.RageHotKey.JustPressed) { - if (gaelRageCooldown == 0 && player.HeldItem.type == ModContent.ItemType() && + if (gaelRageCooldown == 0 && player.ActiveItem().type == ModContent.ItemType() && rage > 0) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SilvaDispel"), (int)player.position.X, (int)player.position.Y); @@ -3220,7 +3248,21 @@ namespace CalamityMod.CalPlayer { meleeSpeedMult += 0.1f; } - if (CalamityMod.CalamityConfig.ProficiencyEnabled) + if (bloodyWormTooth) + { + if (player.statLife < (int)(player.statLifeMax2 * 0.5)) + meleeSpeedMult += 0.1f; + else + meleeSpeedMult += 0.05f; + } + if (aquaticScourgeLore) + { + if (player.wellFed) + meleeSpeedMult += 0.025f; + else + meleeSpeedMult -= 0.025f; + } + if (CalamityMod.CalamityConfig.ProficiencyEnabled) { meleeSpeedMult += GetMeleeSpeedBonus(); } @@ -3349,12 +3391,12 @@ namespace CalamityMod.CalPlayer { CalamityPlayerMiscEffects.CalamityPostUpdateMiscEffects(player, mod); - if (player.HeldItem.type == ModContent.ItemType()) + if (player.ActiveItem().type == ModContent.ItemType()) { gaelSwitchTimer = GaelSwitchPhase.LoseRage; rage += (int)MathHelper.Min(5, 10000 - rage); } - else if (player.HeldItem.type != ModContent.ItemType() && gaelSwitchTimer == GaelSwitchPhase.LoseRage) + else if (player.ActiveItem().type != ModContent.ItemType() && gaelSwitchTimer == GaelSwitchPhase.LoseRage) { rage = 0; gaelSwitchTimer = GaelSwitchPhase.None; @@ -3574,7 +3616,7 @@ namespace CalamityMod.CalPlayer } } } - if (invincible && player.inventory[player.selectedItem].type != ModContent.ItemType()) + if (invincible && player.ActiveItem().type != ModContent.ItemType()) { if (player.statLife <= 0) { @@ -4400,7 +4442,7 @@ namespace CalamityMod.CalPlayer { target.AddBuff(BuffID.Midas, 120, false); } - if (ZoneCalamity && CalamityMod.fireWeaponList.Contains(player.inventory[player.selectedItem].type)) + if (ZoneCalamity && CalamityMod.fireWeaponList.Contains(player.ActiveItem().type)) { target.AddBuff(ModContent.BuffType(), 240, false); } @@ -4718,7 +4760,7 @@ namespace CalamityMod.CalPlayer { target.AddBuff(BuffID.Midas, 120, false); } - if (ZoneCalamity && CalamityMod.fireWeaponList.Contains(player.inventory[player.selectedItem].type)) + if (ZoneCalamity && CalamityMod.fireWeaponList.Contains(player.ActiveItem().type)) { target.AddBuff(ModContent.BuffType(), 240, false); } @@ -4735,7 +4777,7 @@ namespace CalamityMod.CalPlayer target.AddBuff(BuffID.Venom, 120, false); } } - if (proj.type == ProjectileID.IchorArrow && player.inventory[player.selectedItem].type == ModContent.ItemType()) + if (proj.type == ProjectileID.IchorArrow && player.ActiveItem().type == ModContent.ItemType()) { target.AddBuff(BuffID.Midas, 300, false); } @@ -4975,7 +5017,7 @@ namespace CalamityMod.CalPlayer 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]; + Item heldItem = player.ActiveItem(); if (isTrueMelee && soaring) { @@ -5393,12 +5435,7 @@ namespace CalamityMod.CalPlayer } if (umbraphileSet && proj.Calamity().rogue && (Main.rand.NextBool(4) || proj.Calamity().stealthStrike)) { - int newDamage = (int)(proj.damage * 0.25); - if (newDamage > 50) - { - newDamage = (int)((proj.damage * 0.25 - 50) * 0.1) + 50; - } - Projectile.NewProjectile(proj.Center.X, proj.Center.Y, 0f, 0f, ModContent.ProjectileType(), newDamage, 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(proj.Center.X, proj.Center.Y, 0f, 0f, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.25, 50), 0f, player.whoAmI, 0f, 0f); } if (bloodflareMelee && isTrueMelee) { @@ -5622,25 +5659,28 @@ namespace CalamityMod.CalPlayer #region Modify Hit By Proj public override void ModifyHitByProjectile(Projectile proj, ref int damage, ref bool crit) { - if (player.HeldItem.type == ModContent.ItemType() - && proj.active && proj.hostile && player.altFunctionUse == 2 && Main.rand.NextBool(2)) - { - for (int j = 0; j < 3; j++) - { - int dustIndex = Dust.NewDust(proj.position, proj.width, proj.height, 31, 0f, 0f, 0, default, 1f); - Main.dust[dustIndex].velocity *= 0.3f; - } - int damage2 = (int)(GaelsGreatsword.BaseDamage * Main.LocalPlayer.MeleeDamage()); - proj.hostile = false; - proj.friendly = true; - proj.velocity *= -1f; - proj.damage = damage2; - proj.penetrate = 1; - player.immune = true; - player.immuneNoBlink = true; - player.immuneTime = 4; - damage = 0; - } + if (CalamityMod.projectileDestroyExceptionList.TrueForAll(x => proj.type != x)) + { + if (player.ActiveItem().type == ModContent.ItemType() + && proj.active && proj.hostile && player.altFunctionUse == 2 && Main.rand.NextBool(2)) + { + for (int j = 0; j < 3; j++) + { + int dustIndex = Dust.NewDust(proj.position, proj.width, proj.height, 31, 0f, 0f, 0, default, 1f); + Main.dust[dustIndex].velocity *= 0.3f; + } + int damage2 = (int)(GaelsGreatsword.BaseDamage * Main.LocalPlayer.MeleeDamage()); + proj.hostile = false; + proj.friendly = true; + proj.velocity *= -1f; + proj.damage = damage2; + proj.penetrate = 1; + player.immune = true; + player.immuneNoBlink = true; + player.immuneTime = 4; + damage = 0; + } + } int bossRushDamage = (Main.expertMode ? 125 : 150) + (CalamityWorld.bossRushStage / 2); if (CalamityWorld.bossRushActive) { @@ -5824,46 +5864,49 @@ namespace CalamityMod.CalPlayer //1 second for DM lightning, 2 seconds for Storm Weaver/Cultist lightning } } - if (projRef && proj.active && !proj.friendly && proj.hostile && damage > 0 && Main.rand.NextBool(20)) - { - player.statLife += damage; - player.HealEffect(damage); - proj.hostile = false; - proj.friendly = true; - proj.velocity.X = -proj.velocity.X; - proj.velocity.Y = -proj.velocity.Y; - } - if (projRefRare && proj.active && !proj.friendly && proj.hostile && damage > 0 && Main.rand.NextBool(2)) - { - proj.hostile = false; - proj.friendly = true; - proj.velocity.X = -proj.velocity.X * 2f; - proj.velocity.Y = -proj.velocity.Y * 2f; - proj.damage *= 10; - projRefRareLifeRegenCounter = 120; - projTypeJustHitBy = proj.type; - } - if (aSparkRare && proj.active && !proj.friendly && proj.hostile && damage > 0) - { - if (proj.type == ProjectileID.BulletSnowman || proj.type == ProjectileID.BulletDeadeye || proj.type == ProjectileID.SniperBullet) - { - proj.hostile = false; - proj.friendly = true; - proj.velocity.X = -proj.velocity.X; - proj.velocity.Y = -proj.velocity.Y; - proj.damage *= 8; - } - } - if (daedalusReflect && proj.active && !proj.friendly && proj.hostile && damage > 0 && Main.rand.NextBool(3)) - { - int healAmt = damage / 5; - player.statLife += healAmt; - player.HealEffect(healAmt); - proj.hostile = false; - proj.friendly = true; - proj.velocity.X = -proj.velocity.X; - proj.velocity.Y = -proj.velocity.Y; - } + if (CalamityMod.projectileDestroyExceptionList.TrueForAll(x => proj.type != x)) + { + if (projRef && proj.active && !proj.friendly && proj.hostile && damage > 0 && Main.rand.NextBool(20)) + { + player.statLife += damage; + player.HealEffect(damage); + proj.hostile = false; + proj.friendly = true; + proj.velocity.X = -proj.velocity.X; + proj.velocity.Y = -proj.velocity.Y; + } + if (projRefRare && proj.active && !proj.friendly && proj.hostile && damage > 0 && Main.rand.NextBool(2)) + { + proj.hostile = false; + proj.friendly = true; + proj.velocity.X = -proj.velocity.X * 2f; + proj.velocity.Y = -proj.velocity.Y * 2f; + proj.damage *= 10; + projRefRareLifeRegenCounter = 120; + projTypeJustHitBy = proj.type; + } + if (aSparkRare && proj.active && !proj.friendly && proj.hostile && damage > 0) + { + if (proj.type == ProjectileID.BulletSnowman || proj.type == ProjectileID.BulletDeadeye || proj.type == ProjectileID.SniperBullet) + { + proj.hostile = false; + proj.friendly = true; + proj.velocity.X = -proj.velocity.X; + proj.velocity.Y = -proj.velocity.Y; + proj.damage *= 8; + } + } + if (daedalusReflect && proj.active && !proj.friendly && proj.hostile && damage > 0 && Main.rand.NextBool(3)) + { + int healAmt = damage / 5; + player.statLife += healAmt; + player.HealEffect(healAmt); + proj.hostile = false; + proj.friendly = true; + proj.velocity.X = -proj.velocity.X; + proj.velocity.Y = -proj.velocity.Y; + } + } } #endregion @@ -6134,7 +6177,7 @@ namespace CalamityMod.CalPlayer } } - if (lol || (invincible && player.inventory[player.selectedItem].type != ModContent.ItemType())) + if (lol || (invincible && player.ActiveItem().type != ModContent.ItemType())) { return false; } @@ -6225,6 +6268,10 @@ namespace CalamityMod.CalPlayer if (encased) { damage = (int)(damage * 0.7); + } + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && player.ActiveItem().type == ModContent.ItemType()) + { + damage = (int)(damage * 0.5); } if (theBee && player.statLife >= player.statLifeMax2 && theBeeCooldown <= 0) { @@ -6427,34 +6474,41 @@ namespace CalamityMod.CalPlayer } } } - if (aBrain) + if (aBrain || amalgam) { for (int m = 0; m < Main.maxNPCs; m++) { if (Main.npc[m].active && !Main.npc[m].friendly) { - float arg_67A_0 = (Main.npc[m].Center - player.Center).Length(); - float num10 = (float)Main.rand.Next(200 + (int)damage / 2, 301 + (int)damage * 2); - if (num10 > 500f) + float npcDist = (Main.npc[m].Center - player.Center).Length(); + float range = (float)Main.rand.Next(200 + (int)damage / 2, 301 + (int)damage * 2); + if (range > 500f) { - num10 = 500f + (num10 - 500f) * 0.75f; + range = 500f + (range - 500f) * 0.75f; } - if (num10 > 700f) + if (range > 700f) { - num10 = 700f + (num10 - 700f) * 0.5f; + range = 700f + (range - 700f) * 0.5f; } - if (num10 > 900f) + if (range > 900f) { - num10 = 900f + (num10 - 900f) * 0.25f; + range = 900f + (range - 900f) * 0.25f; } - if (arg_67A_0 < num10) + if (npcDist < range) { - float num11 = (float)Main.rand.Next(90 + (int)damage / 3, 300 + (int)damage / 2); - Main.npc[m].AddBuff(BuffID.Confused, (int)num11, false); + float duration = (float)Main.rand.Next(90 + (int)damage / 3, 300 + (int)damage / 2); + Main.npc[m].AddBuff(BuffID.Confused, (int)duration, false); + if (amalgam) + { + Main.npc[m].AddBuff(ModContent.BuffType(), (int)duration, false); + Main.npc[m].AddBuff(ModContent.BuffType(), (int)duration, false); + Main.npc[m].AddBuff(ModContent.BuffType(), (int)duration, false); + Main.npc[m].AddBuff(ModContent.BuffType(), (int)duration, false); + } } } } - //spawn the harmless brain images that are actually projectiles + //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) @@ -9285,7 +9339,8 @@ namespace CalamityMod.CalPlayer player.rangedCrit += boost; player.magicCrit += boost; player.thrownCrit += boost; - throwingCrit += boost; + // Rogue weapons benefit from throwing crit AND rogue crit, so don't add both. + // throwingCrit += boost; } #endregion @@ -9346,7 +9401,15 @@ namespace CalamityMod.CalPlayer // This doesn't trigger stealth strike effects (ConsumeStealthStrike instead of StealthStrike) // so non-rogue weapons can't call lasers down from the sky and such. // Using any item which deals no damage or is a tool doesn't consume stealth. - bool playerUsingWeapon = player.HeldItem.damage > 0 && player.HeldItem.pick <= 0 && player.HeldItem.hammer <= 0 && player.HeldItem.axe <= 0; + Item it = player.ActiveItem(); + bool hasDamage = it.damage > 0; + bool hasHitboxes = !it.noMelee || it.shoot > 0; + bool isPickaxe = it.pick > 0; + bool isAxe = it.axe > 0; + bool isHammer = it.hammer > 0; + bool isPlaced = it.createTile != -1; + bool hasNonWeaponFunction = isPickaxe || isAxe || isHammer || isPlaced; + bool playerUsingWeapon = hasDamage && hasHitboxes && !hasNonWeaponFunction; if (!stealthStrikeThisFrame && player.itemAnimation == player.itemAnimationMax - 1 && playerUsingWeapon) ConsumeStealthByAttacking(); } @@ -9396,7 +9459,7 @@ namespace CalamityMod.CalPlayer stealthGenMoving += 0.15f; } - if (CalamityMod.daggerList.Contains(player.inventory[player.selectedItem].type) && player.invis) + if (CalamityMod.daggerList.Contains(player.ActiveItem().type) && player.invis) { stealthGenStandstill += 0.08f; stealthGenMoving += 0.08f; diff --git a/CalPlayer/CalamityPlayerFishing.cs b/CalPlayer/CalamityPlayerFishing.cs index fdd3b70157..9f2d5cf8ac 100644 --- a/CalPlayer/CalamityPlayerFishing.cs +++ b/CalPlayer/CalamityPlayerFishing.cs @@ -591,7 +591,7 @@ namespace CalamityMod.CalPlayer if (modPlayer.ZoneAbyss || modPlayer.ZoneSulphur) canSulphurFish = true; - Item item = player.inventory[player.selectedItem]; + Item item = player.ActiveItem(); if (!canSulphurFish || item.fishingPole <= 0 || item.holdStyle != 1) fishingLevel = -1; } diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 317d93e20a..558a5f6620 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -272,6 +272,10 @@ namespace CalamityMod.CalPlayer { modPlayer.alcoholPoisonLevel++; } + if (modPlayer.fabsolVodka) + { + modPlayer.alcoholPoisonLevel++; + } if (modPlayer.fireball) { modPlayer.alcoholPoisonLevel++; @@ -533,7 +537,7 @@ namespace CalamityMod.CalPlayer } } - if (modPlayer.weakPetrification || CalamityWorld.bossRushActive) + if (modPlayer.weakPetrification) { if (player.mount.Active) player.mount.Dismount(player); diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 942d420842..711657332f 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -280,7 +280,7 @@ namespace CalamityMod.CalPlayer } // If Revengeance Mode is not active, then set rippers to zero - else if(player.whoAmI == Main.myPlayer) + else if (player.whoAmI == Main.myPlayer) { modPlayer.rage = 0; modPlayer.adrenaline = 0; @@ -595,7 +595,7 @@ namespace CalamityMod.CalPlayer if (Main.raining) { - float frequencyMult = 1f - Main.cloudAlpha; // 1 to 0.11 + float frequencyMult = (1f - Main.cloudAlpha) * CalamityMod.CalamityConfig.WeatherEffectRateMultiplier; // 3 to 0.055 Vector2 spawnPoint = new Vector2(player.Center.X + (float)Main.rand.Next(-1000, 1001), player.Center.Y - (float)Main.rand.Next(700, 801)); Tile tileSafely = Framing.GetTileSafely((int)(spawnPoint.X / 16f), (int)(spawnPoint.Y / 16f)); @@ -609,7 +609,7 @@ namespace CalamityMod.CalPlayer Vector2 velocity = new Vector2(windVelocity * 0.2f, 3f * Main.rand.NextFloat()); if (player.miscCounter % divisor == 0 && Main.rand.NextBool(3)) - Projectile.NewProjectile(spawnPoint.X, spawnPoint.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), 20, 0f, player.whoAmI, 1f, 0f); + Projectile.NewProjectile(spawnPoint.X, spawnPoint.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), 20, 0f, player.whoAmI, 2f, 0f); } } else @@ -885,6 +885,8 @@ namespace CalamityMod.CalPlayer modPlayer.gainRageCooldown--; if (modPlayer.galileoCooldown > 0) modPlayer.galileoCooldown--; + if (modPlayer.soundCooldown > 0) + modPlayer.soundCooldown--; if (modPlayer.raiderCooldown > 0) modPlayer.raiderCooldown--; if (modPlayer.gSabatonCooldown > 0) @@ -945,6 +947,8 @@ namespace CalamityMod.CalPlayer modPlayer.sulphurBubbleCooldown--; if (modPlayer.forbiddenCooldown > 0) modPlayer.forbiddenCooldown--; + if (modPlayer.tornadoCooldown > 0) + modPlayer.tornadoCooldown--; if (modPlayer.ladHearts > 0) modPlayer.ladHearts--; if (modPlayer.titanBoost > 0) @@ -1305,7 +1309,7 @@ namespace CalamityMod.CalPlayer player.endurance += 0.01f; player.statDefense += 2; } - if (!modPlayer.polarisBoost || player.inventory[player.selectedItem].type != ModContent.ItemType()) + if (!modPlayer.polarisBoost || player.ActiveItem().type != ModContent.ItemType()) { modPlayer.polarisBoost = false; if (player.FindBuffIndex(ModContent.BuffType()) > -1) @@ -1436,7 +1440,6 @@ namespace CalamityMod.CalPlayer player.statDefense += 1; player.allDamage += 0.025f; modPlayer.AllCritBoost(1); - player.meleeSpeed += 0.025f; player.minionKB += 0.25f; player.moveSpeed += 0.1f; } @@ -1445,7 +1448,6 @@ namespace CalamityMod.CalPlayer player.statDefense -= 1; player.allDamage -= 0.025f; modPlayer.AllCritBoost(-1); - player.meleeSpeed -= 0.025f; player.minionKB -= 0.25f; player.moveSpeed -= 0.1f; } @@ -2563,27 +2565,27 @@ namespace CalamityMod.CalPlayer } } - if (CalamityMod.scopedWeaponList.Contains(player.inventory[player.selectedItem].type)) + if (CalamityMod.scopedWeaponList.Contains(player.ActiveItem().type)) player.scope = true; - if (CalamityMod.highTestFishList.Contains(player.inventory[player.selectedItem].type)) + if (CalamityMod.highTestFishList.Contains(player.ActiveItem().type)) player.accFishingLine = true; - if (CalamityMod.boomerangList.Contains(player.inventory[player.selectedItem].type) && player.invis) + if (CalamityMod.boomerangList.Contains(player.ActiveItem().type) && player.invis) modPlayer.throwingDamage += 0.1f; - if (CalamityMod.javelinList.Contains(player.inventory[player.selectedItem].type) && player.invis) + if (CalamityMod.javelinList.Contains(player.ActiveItem().type) && player.invis) player.armorPenetration += 5; - if (CalamityMod.flaskBombList.Contains(player.inventory[player.selectedItem].type) && player.invis) + if (CalamityMod.flaskBombList.Contains(player.ActiveItem().type) && player.invis) modPlayer.throwingVelocity += 0.1f; - if (CalamityMod.spikyBallList.Contains(player.inventory[player.selectedItem].type) && player.invis) + if (CalamityMod.spikyBallList.Contains(player.ActiveItem().type) && player.invis) modPlayer.throwingCrit += 10; if (modPlayer.planarSpeedBoost != 0) { - if (player.inventory[player.selectedItem].type != ModContent.ItemType()) + if (player.ActiveItem().type != ModContent.ItemType()) modPlayer.planarSpeedBoost = 0; } @@ -2593,10 +2595,10 @@ namespace CalamityMod.CalPlayer !modPlayer.ZoneSunkenSea && !player.ZoneSnow && !player.ZoneCorrupt && !player.ZoneCrimson && !player.ZoneHoly && !player.ZoneDesert && !player.ZoneUndergroundDesert && !player.ZoneGlowshroom && !player.ZoneDungeon && !player.ZoneBeach && !player.ZoneMeteor; - if (player.ZoneUnderworldHeight && !modPlayer.ZoneCalamity && CalamityMod.fireWeaponList.Contains(player.inventory[player.selectedItem].type)) + if (player.ZoneUnderworldHeight && !modPlayer.ZoneCalamity && CalamityMod.fireWeaponList.Contains(player.ActiveItem().type)) player.endurance += 0.03f; - if ((player.ZoneDesert || player.ZoneUndergroundDesert) && CalamityMod.daggerList.Contains(player.inventory[player.selectedItem].type)) + if ((player.ZoneDesert || player.ZoneUndergroundDesert) && CalamityMod.daggerList.Contains(player.ActiveItem().type)) player.scope = true; if (modPlayer.ZoneSunkenSea) @@ -2605,7 +2607,7 @@ namespace CalamityMod.CalPlayer player.ignoreWater = true; } - if (player.ZoneSnow && CalamityMod.iceWeaponList.Contains(player.inventory[player.selectedItem].type)) + if (player.ZoneSnow && CalamityMod.iceWeaponList.Contains(player.ActiveItem().type)) player.statDefense += 5; if (modPlayer.ZoneAstral) @@ -2614,7 +2616,7 @@ namespace CalamityMod.CalPlayer player.wingTimeMax = (int)((double)player.wingTimeMax * 1.05); } - if (player.ZoneJungle && CalamityMod.natureWeaponList.Contains(player.inventory[player.selectedItem].type)) + if (player.ZoneJungle && CalamityMod.natureWeaponList.Contains(player.ActiveItem().type)) player.AddBuff(BuffID.DryadsWard, 5, true); // Dryad's Blessing if (modPlayer.ZoneAbyss) @@ -2634,7 +2636,7 @@ namespace CalamityMod.CalPlayer player.endurance += 0.05f; } - if (player.ZoneRockLayerHeight && ZoneForest && CalamityMod.flaskBombList.Contains(player.inventory[player.selectedItem].type)) + if (player.ZoneRockLayerHeight && ZoneForest && CalamityMod.flaskBombList.Contains(player.ActiveItem().type)) player.blackBelt = true; if (player.ZoneHoly) @@ -2949,8 +2951,6 @@ namespace CalamityMod.CalPlayer if (modPlayer.manaOverloader) { player.magicDamage += 0.06f; - if (player.statMana < (int)(player.statManaMax2 * 0.1)) - player.ghostHeal = true; } if (modPlayer.twinsLore) @@ -2979,13 +2979,11 @@ namespace CalamityMod.CalPlayer if (player.statLife < (int)(player.statLifeMax2 * 0.5)) { player.meleeDamage += 0.1f; - player.meleeSpeed += 0.1f; player.endurance += 0.1f; } else { player.meleeDamage += 0.05f; - player.meleeSpeed += 0.05f; player.endurance += 0.05f; } } @@ -3193,7 +3191,7 @@ namespace CalamityMod.CalPlayer } // Navy Fishing Rod's electric aura when in-use - if (player.inventory[player.selectedItem].type == ModContent.ItemType() && player.ownedProjectileCounts[ModContent.ProjectileType()] != 0) + if (player.ActiveItem().type == ModContent.ItemType() && player.ownedProjectileCounts[ModContent.ProjectileType()] != 0) { const int FramesPerHit = 120; @@ -3503,8 +3501,8 @@ namespace CalamityMod.CalPlayer } } - if (player.meleeSpeed < 0.5f) - player.meleeSpeed = 0.5f; + /*if (player.meleeSpeed < 0.5f) + player.meleeSpeed = 0.5f;*/ // 10% is converted to 9%, 25% is converted to 20%, 50% is converted to 33%, 75% is converted to 43%, 100% is converted to 50% if (player.endurance > 0f) diff --git a/CalamityMod.cs b/CalamityMod.cs index d8c498aa0c..977555e73a 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -9,7 +9,7 @@ using CalamityMod.Items.Accessories.Wings; using CalamityMod.Items.Ammo.FiniteUse; using CalamityMod.Items.Armor; using CalamityMod.Items.Armor.Vanity; -using CalamityMod.Items.Dyes; +using CalamityMod.Items.Dyes.HairDye; using CalamityMod.Items.Fishing.AstralCatches; using CalamityMod.Items.Fishing.BrimstoneCragCatches; using CalamityMod.Items.Fishing.FishingRods; @@ -124,9 +124,10 @@ namespace CalamityMod // DR data structure public static SortedDictionary DRValues; + public static SortedDictionary bossKillTimes; - // Lists - public static IList donatorList; + // Lists + public static IList donatorList; public static List rangedProjectileExceptionList; public static List projectileDestroyExceptionList; public static List projectileMinionList; @@ -149,7 +150,9 @@ namespace CalamityMod public static List thirtyThreeDamageBuffList; //33% buff public static List twentyFiveDamageBuffList; //25% buff public static List twentyDamageBuffList; //20% buff + public static List tenDamageBuffList; //10% buff public static List weaponAutoreuseList; + public static List tenDamageNerfList; //10% nerf public static List quarterDamageNerfList; //25% nerf public static List pumpkinMoonBuffList; public static List frostMoonBuffList; @@ -236,6 +239,7 @@ namespace CalamityMod SetupLists(); SetupVanillaDR(); + SetupBossKillTimes(); SetupThoriumBossDR(thorium); CalamityLocalization.AddLocalizations(); @@ -339,6 +343,8 @@ namespace CalamityMod DRValues?.Clear(); DRValues = null; + bossKillTimes?.Clear(); + bossKillTimes = null; donatorList = null; rangedProjectileExceptionList = null; @@ -362,7 +368,9 @@ namespace CalamityMod fiftyDamageBuffList = null; thirtyThreeDamageBuffList = null; twentyFiveDamageBuffList = null; + tenDamageBuffList = null; weaponAutoreuseList = null; + tenDamageNerfList = null; quarterDamageNerfList = null; pumpkinMoonBuffList = null; frostMoonBuffList = null; @@ -649,7 +657,16 @@ namespace CalamityMod ModContent.ProjectileType(), ModContent.ProjectileType(), - ModContent.ProjectileType() + ModContent.ProjectileType(), + + //Some hostile boss projectiles + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType() }; projectileMinionList = new List() @@ -1244,7 +1261,8 @@ namespace CalamityMod ItemID.BreakerBlade, ItemID.MonkStaffT2, ItemID.ProximityMineLauncher, - ItemID.FireworksLauncher + ItemID.FireworksLauncher, + ItemID.ShadowbeamStaff }; sixtySixDamageBuffList = new List() @@ -1311,6 +1329,12 @@ namespace CalamityMod ItemID.TacticalShotgun }; + tenDamageBuffList = new List() + { + ItemID.MagnetSphere, + ItemID.BatScepter + }; + weaponAutoreuseList = new List() { ItemID.NightsEdge, @@ -1328,12 +1352,20 @@ namespace CalamityMod ItemID.StylistKilLaKillScissorsIWish }; + tenDamageNerfList = new List() + { + ItemID.Phantasm + }; + quarterDamageNerfList = new List() { + ItemID.Razorpine, ItemID.DaedalusStormbow, ItemID.PhoenixBlaster, - ItemID.BlizzardStaff, - ItemID.DD2BetsyBow + ItemID.DD2BetsyBow, + ItemID.InfluxWaver, + ItemID.Xenopopper, + ItemID.ElectrosphereLauncher }; pumpkinMoonBuffList = new List() @@ -2525,13 +2557,14 @@ namespace CalamityMod { NPCID.Crab, 0.05f }, { NPCID.Crawdad, 0.2f }, { NPCID.Crawdad2, 0.2f }, - { NPCID.CultistBoss, 0.05f }, + { NPCID.CultistBoss, 0.1f }, { NPCID.DD2Betsy, 0.1f }, { NPCID.DD2OgreT2, 0.1f }, { NPCID.DD2OgreT3, 0.15f }, { NPCID.DeadlySphere, 0.4f }, { NPCID.DiabolistRed, 0.2f }, { NPCID.DiabolistWhite, 0.2f }, + { NPCID.DukeFishron, 0.1f }, { NPCID.DungeonGuardian, 0.999999f }, { NPCID.DungeonSpirit, 0.2f }, { NPCID.ElfCopter, 0.15f }, @@ -2576,7 +2609,9 @@ namespace CalamityMod { NPCID.Paladin, 0.45f }, { NPCID.PirateCaptain, 0.05f }, { NPCID.PirateShipCannon, 0.15f }, - { NPCID.PossessedArmor, 0.25f }, + { NPCID.Plantera, 0.15f }, + { NPCID.PlanterasTentacle, 0.1f }, + { NPCID.PossessedArmor, 0.25f }, { NPCID.PresentMimic, 0.3f }, { NPCID.PrimeCannon, 0.2f }, { NPCID.PrimeLaser, 0.2f }, @@ -2617,7 +2652,7 @@ namespace CalamityMod #region Thorium Boss DR private void SetupThoriumBossDR(Mod thorium) { - if (thorium is null || !CalamityMod.CalamityConfig.RevengeanceAndDeathThoriumBossBuff) + if (thorium is null || !CalamityConfig.RevengeanceAndDeathThoriumBossBuff) return; void ThoriumDR(string npcName, float dr) { @@ -2650,10 +2685,93 @@ namespace CalamityMod ThoriumDR("Omnicide", 0.3f); ThoriumDR("Abyssion", 0.35f); } - #endregion + #endregion - #region Music - public override void UpdateMusic(ref int music, ref MusicPriority priority) + #region Boss Kill Times + private void SetupBossKillTimes() + { + bossKillTimes = new SortedDictionary { + { NPCID.KingSlime, 3600 }, + { NPCID.EyeofCthulhu, 5400 }, + { NPCID.EaterofWorldsHead, 7200 }, + { NPCID.EaterofWorldsBody, 7200 }, + { NPCID.EaterofWorldsTail, 7200 }, + { NPCID.BrainofCthulhu, 5400 }, + { NPCID.QueenBee, 7200 }, + { NPCID.SkeletronHead, 9000 }, + { NPCID.WallofFlesh, 10800 }, + { NPCID.WallofFleshEye, 10800 }, + { NPCID.Spazmatism, 10800 }, + { NPCID.Retinazer, 10800 }, + { NPCID.TheDestroyer, 10800 }, + { NPCID.TheDestroyerBody, 10800 }, + { NPCID.TheDestroyerTail, 10800 }, + { NPCID.SkeletronPrime, 10800 }, + { NPCID.Plantera, 10800 }, + { NPCID.Golem, 10800 }, + { NPCID.GolemHead, 3600 }, + { NPCID.DukeFishron, 9000 }, + { NPCID.CultistBoss, 9000 }, + { NPCID.MoonLordCore, 14400 }, + { NPCID.MoonLordHand, 7200 }, + { NPCID.MoonLordHead, 7200 }, + { ModContent.NPCType(), 3600 }, + { ModContent.NPCType(), 3600 }, + { ModContent.NPCType(), 3600 }, + { ModContent.NPCType(), 5400 }, + { ModContent.NPCType(), 1800 }, + { ModContent.NPCType(), 5400 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 3600 }, + { ModContent.NPCType(), 3600 }, + { ModContent.NPCType(), 3600 }, + { ModContent.NPCType(), 3600 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 1200 }, + { ModContent.NPCType(), 11400 }, + { ModContent.NPCType(), 9000 }, + { ModContent.NPCType(), 9000 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 5400 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 14400 }, + { ModContent.NPCType(), 1200 }, + { ModContent.NPCType(), 1200 }, + { ModContent.NPCType(), 1200 }, + { ModContent.NPCType(), 5400 }, + { ModContent.NPCType(), 5400 }, + { ModContent.NPCType(), 5400 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 14400 } + }; + } + #endregion + + #region Music + public override void UpdateMusic(ref int music, ref MusicPriority priority) { Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic"); if (Main.musicVolume != 0) @@ -3298,7 +3416,7 @@ namespace CalamityMod #region Lighting const float MaxCaveDarkness = -0.3f; - const float MaxSignusDarkness = -0.5f; + const float MaxSignusDarkness = -0.4f; const float MaxAbyssDarkness = -0.7f; public override void ModifyLightingBrightness(ref float scale) { @@ -3566,6 +3684,6 @@ namespace CalamityMod AcidRainUIDrawFadeSync, AcidRainOldDukeSummonSync, GaelsGreatswordSwingSync, - SpawnSuperDummy, + SpawnSuperDummy } } diff --git a/Configs.cs b/Configs.cs index 2970ba31be..d45ffccf1e 100644 --- a/Configs.cs +++ b/Configs.cs @@ -88,6 +88,11 @@ namespace CalamityMod [Tooltip("Boosts the player's mining speed by 75%")] public bool MiningSpeedBoost { get; set; } + [DefaultValue(false)] + [Label("Extra Damage Reduction for Bosses")] + [Tooltip("Grants extra damage reduction for bosses for every boss encounter, regardless if you've defeated the boss already or not")] + public bool ExtraBossDR { get; set; } + [Label("Boss Health Percentage Boost")] [Tooltip("Boosts the health of bosses to a maximum of +900% health")] [Range(0f, 900f)] @@ -158,6 +163,14 @@ namespace CalamityMod [Tooltip("Buffs the health of Thorium bosses if Revengeance or Death is enabled")] public bool RevengeanceAndDeathThoriumBossBuff { get; set; } + [Header("Death Mode Changes")] + + [DefaultValue(1f)] + [Range(0.5f, 3f)] + [Label("Weather Effect Rate Multiplier")] + [Tooltip("Affects all Death Mode weather projectiles, increase to decrease the amount of projectiles, decrease to increase the amount of projectiles")] + public float WeatherEffectRateMultiplier { get; set; } + [Header("Boss Rush Curses")] [DefaultValue(false)] diff --git a/Effects/Dyes/AstralBlueDyeShader.xnb b/Effects/Dyes/AstralBlueDyeShader.xnb new file mode 100644 index 0000000000..9757c6ec19 Binary files /dev/null and b/Effects/Dyes/AstralBlueDyeShader.xnb differ diff --git a/Effects/Dyes/AstralOrangeDyeShader.xnb b/Effects/Dyes/AstralOrangeDyeShader.xnb new file mode 100644 index 0000000000..c420c03742 Binary files /dev/null and b/Effects/Dyes/AstralOrangeDyeShader.xnb differ diff --git a/Effects/Dyes/AstralSwirlDyeShader.xnb b/Effects/Dyes/AstralSwirlDyeShader.xnb new file mode 100644 index 0000000000..0d70f87796 Binary files /dev/null and b/Effects/Dyes/AstralSwirlDyeShader.xnb differ diff --git a/Effects/Dyes/CeaselessDyeShader.xnb b/Effects/Dyes/CeaselessDyeShader.xnb new file mode 100644 index 0000000000..027bcbf063 Binary files /dev/null and b/Effects/Dyes/CeaselessDyeShader.xnb differ diff --git a/Effects/Dyes/DefiledFlameDyeShader.xnb b/Effects/Dyes/DefiledFlameDyeShader.xnb new file mode 100644 index 0000000000..6ffdc1214b Binary files /dev/null and b/Effects/Dyes/DefiledFlameDyeShader.xnb differ diff --git a/Effects/Dyes/DragonSoulDyeShader.xnb b/Effects/Dyes/DragonSoulDyeShader.xnb new file mode 100644 index 0000000000..f1f7b0901c Binary files /dev/null and b/Effects/Dyes/DragonSoulDyeShader.xnb differ diff --git a/Effects/Dyes/ElementalDyeShader.xnb b/Effects/Dyes/ElementalDyeShader.xnb new file mode 100644 index 0000000000..d1eb643a82 Binary files /dev/null and b/Effects/Dyes/ElementalDyeShader.xnb differ diff --git a/Effects/Dyes/EndothermicDyeShader.xnb b/Effects/Dyes/EndothermicDyeShader.xnb new file mode 100644 index 0000000000..3477734ded Binary files /dev/null and b/Effects/Dyes/EndothermicDyeShader.xnb differ diff --git a/Effects/Dyes/NightmareDyeShader.xnb b/Effects/Dyes/NightmareDyeShader.xnb new file mode 100644 index 0000000000..ebbf339232 Binary files /dev/null and b/Effects/Dyes/NightmareDyeShader.xnb differ diff --git a/Effects/Dyes/ReaverDyeShader.xnb b/Effects/Dyes/ReaverDyeShader.xnb new file mode 100644 index 0000000000..a1985cce56 Binary files /dev/null and b/Effects/Dyes/ReaverDyeShader.xnb differ diff --git a/Effects/Dyes/ShadowspecDyeShader.xnb b/Effects/Dyes/ShadowspecDyeShader.xnb new file mode 100644 index 0000000000..6d2da86ec1 Binary files /dev/null and b/Effects/Dyes/ShadowspecDyeShader.xnb differ diff --git a/Effects/Dyes/StratusDyeShader.xnb b/Effects/Dyes/StratusDyeShader.xnb new file mode 100644 index 0000000000..60b17c7761 Binary files /dev/null and b/Effects/Dyes/StratusDyeShader.xnb differ diff --git a/ExtraTextures/UI/NPCAlertDisplay.png b/ExtraTextures/UI/NPCAlertDisplay.png index 45f8ee35bd..fae5814dc7 100644 Binary files a/ExtraTextures/UI/NPCAlertDisplay.png and b/ExtraTextures/UI/NPCAlertDisplay.png differ diff --git a/Gores/CryoSpirit.png b/Gores/CryoSpirit.png index 91cf54199d..2ca4fe1bb5 100644 Binary files a/Gores/CryoSpirit.png and b/Gores/CryoSpirit.png differ diff --git a/Items/Accessories/DukeScales.cs b/Items/Accessories/DukeScales.cs index b9f6ae81d3..fc0923c027 100644 --- a/Items/Accessories/DukeScales.cs +++ b/Items/Accessories/DukeScales.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Accessories Tooltip.SetDefault("While under the effects of a damaging debuff, you gain 10% increased damage and 5% crit\n" + "For every 25% of lost life, you gain 6% increased damage and 3% crit\n" + "This will max out at 18% increased damage and 9% crit when under 25% life\n" + - "Provides immunity to poisoned, venom, and sulphruic poisoning"); + "Provides immunity to poisoned, venom, and sulphuric poisoning"); } public override void SetDefaults() diff --git a/Items/Accessories/ElementalQuiver.cs b/Items/Accessories/ElementalQuiver.cs index 23b26e354e..f1a4cff40a 100644 --- a/Items/Accessories/ElementalQuiver.cs +++ b/Items/Accessories/ElementalQuiver.cs @@ -14,8 +14,8 @@ namespace CalamityMod.Items.Accessories DisplayName.SetDefault("Elemental Quiver"); Tooltip.SetDefault("Ranged projectiles have a chance to split\n" + "Ranged weapons have a chance to instantly kill normal enemies\n" + - "10% increased ranged damage and 5% increased ranged critical strike chance\n" + - "20% reduced ammo usage and increased life regen, minion knockback, defense, and pick speed\n" + + "10% increased ranged damage, 5% increased ranged critical strike chance, and 20% reduced ammo usage\n" + + "5 increased defense, 2 increased life regen, and 15% increased pick speed\n" + "Greatly increases arrow speed and grants a 20% chance to not consume arrows"); } @@ -38,7 +38,6 @@ namespace CalamityMod.Items.Accessories player.lifeRegen += 2; player.statDefense += 5; player.pickSpeed -= 0.15f; - player.minionKB += 0.5f; } public override void AddRecipes() diff --git a/Items/Accessories/EtherealTalisman.png b/Items/Accessories/EtherealTalisman.png index a6ba2417cf..4cd07f2b43 100644 Binary files a/Items/Accessories/EtherealTalisman.png and b/Items/Accessories/EtherealTalisman.png differ diff --git a/Items/Accessories/FungalClump.cs b/Items/Accessories/FungalClump.cs index 7e157a9f74..cd885de770 100644 --- a/Items/Accessories/FungalClump.cs +++ b/Items/Accessories/FungalClump.cs @@ -7,6 +7,8 @@ namespace CalamityMod.Items.Accessories { public class FungalClump : ModItem { + public const int FungalClumpDamage = 10; + public override void SetStaticDefaults() { DisplayName.SetDefault("Fungal Clump"); @@ -24,15 +26,7 @@ namespace CalamityMod.Items.Accessories item.accessory = true; } - public override bool CanEquipAccessory(Player player, int slot) - { - CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.fungalClump) - { - return false; - } - return true; - } + public override bool CanEquipAccessory(Player player, int slot) => !player.Calamity().fungalClump; public override void UpdateAccessory(Player player, bool hideVisual) { @@ -46,7 +40,7 @@ namespace CalamityMod.Items.Accessories } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), (int)(10 * player.MinionDamage()), 1f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), (int)(FungalClumpDamage * player.MinionDamage()), 1f, player.whoAmI, 0f, 0f); } } } diff --git a/Items/Accessories/HeartoftheElements.cs b/Items/Accessories/HeartoftheElements.cs index 5ac11c2e5b..ff56822c8e 100644 --- a/Items/Accessories/HeartoftheElements.cs +++ b/Items/Accessories/HeartoftheElements.cs @@ -2,10 +2,12 @@ using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Summon; using CalamityMod.World; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Accessories { @@ -48,165 +50,177 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { + //Don't do anything if the player fucked up somehow, somewhere + if (player.whoAmI != Main.myPlayer || player is null || player.dead) + return; + Lighting.AddLight((int)player.Center.X / 16, (int)player.Center.Y / 16, (float)Main.DiscoR / 255f, (float)Main.DiscoG / 255f, (float)Main.DiscoB / 255f); CalamityPlayer modPlayer = player.Calamity(); modPlayer.allWaifus = !hideVisual; modPlayer.elementalHeart = true; + + player.lifeRegen += hideVisual ? 2 : 1; + player.statLifeMax2 += hideVisual ? 25 : 20; + player.moveSpeed += hideVisual ? 0.12f : 0.1f; + player.jumpSpeedBoost += hideVisual ? 1.1f : 1f; + player.endurance += hideVisual ? 0.06f : 0.05f; + player.statManaMax2 += hideVisual ? 60 : 50; + player.manaCost *= hideVisual ? 0.93f : 0.95f; + player.allDamage += hideVisual ? 0.1f : 0.08f; + + int brimmy = ProjectileType(); + int siren = ProjectileType(); + int healer = ProjectileType(); + int sandy = ProjectileType(); + int cloudy = ProjectileType(); + if (!hideVisual) { - player.lifeRegen += 1; - player.statLifeMax2 += 20; - player.moveSpeed += 0.1f; - player.jumpSpeedBoost += 1.0f; - player.endurance += 0.05f; - player.statManaMax2 += 50; - player.manaCost *= 0.95f; - player.allDamage += 0.08f; - - int damage = NPC.downedMoonlord ? 150 : 90; - float damageMult = CalamityWorld.downedDoG ? 2f : 1f; + Vector2 velocity = new Vector2(0f, -1f); + int damage = NPC.downedMoonlord ? 150 : 90; + float damageMult = CalamityWorld.downedDoG ? 2f : 1f; int elementalDmg = (int)(damage * damageMult * player.MinionDamage()); + float kBack = 2f + player.minionKB; - 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) - { - player.ClearBuff(ModContent.BuffType()); - } - if (player.FindBuffIndex(ModContent.BuffType()) == -1) - { - player.AddBuff(ModContent.BuffType(), 3600, true); - } - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - 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(), elementalDmg, 2f, Main.myPlayer, 0f, 0f); - } - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - 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(), elementalDmg, 2f, Main.myPlayer, 0f, 0f); - } - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), elementalDmg, 2f, Main.myPlayer, 0f, 0f); - } + if (player.ownedProjectileCounts[brimmy] > 1 || player.ownedProjectileCounts[siren] > 1 || + player.ownedProjectileCounts[healer] > 1 || player.ownedProjectileCounts[sandy] > 1 || + player.ownedProjectileCounts[cloudy] > 1) + { + player.ClearBuff(BuffType()); + } + if (player.FindBuffIndex(BuffType()) == -1) + { + player.AddBuff(BuffType(), 3600, true); + } + if (player.ownedProjectileCounts[brimmy] < 1) + { + Projectile.NewProjectile(player.Center, velocity, brimmy, elementalDmg, kBack, player.whoAmI, 0f, 0f); + } + if (player.ownedProjectileCounts[siren] < 1) + { + Projectile.NewProjectile(player.Center, velocity, siren, elementalDmg, kBack, player.whoAmI, 0f, 0f); + } + if (player.ownedProjectileCounts[healer] < 1) + { + Projectile.NewProjectile(player.Center, velocity, healer, elementalDmg, kBack, player.whoAmI, 0f, 0f); + } + if (player.ownedProjectileCounts[sandy] < 1) + { + Projectile.NewProjectile(player.Center, velocity, sandy, elementalDmg, kBack, player.whoAmI, 0f, 0f); + } + if (player.ownedProjectileCounts[cloudy] < 1) + { + Projectile.NewProjectile(player.Center, velocity, cloudy, elementalDmg, kBack, player.whoAmI, 0f, 0f); + } } else { - player.lifeRegen += 2; - player.statLifeMax2 += 25; - player.moveSpeed += 0.12f; - player.jumpSpeedBoost += 1.1f; - player.endurance += 0.06f; - player.statManaMax2 += 60; - player.manaCost *= 0.93f; - player.allDamage += 0.1f; - if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 || player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 || - player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 || player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 || - player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + if (player.ownedProjectileCounts[brimmy] > 0 || player.ownedProjectileCounts[siren] > 0 || + player.ownedProjectileCounts[healer] > 0 || player.ownedProjectileCounts[sandy] > 0 || + player.ownedProjectileCounts[cloudy] > 0) { - player.ClearBuff(ModContent.BuffType()); + player.ClearBuff(BuffType()); } } + + //Flower Boots code if (player.velocity.Y == 0f && player.grappling[0] == -1) { - int num4 = (int)player.Center.X / 16; - int num5 = (int)(player.position.Y + (float)player.height - 1f) / 16; - if (Main.tile[num4, num5] == null) + int x = (int)player.Center.X / 16; + int y = (int)(player.position.Y + (float)player.height - 1f) / 16; + Tile tile = Main.tile[x, y]; + if (tile == null) { - Main.tile[num4, num5] = new Tile(); + tile = new Tile(); } - if (!Main.tile[num4, num5].active() && Main.tile[num4, num5].liquid == 0 && Main.tile[num4, num5 + 1] != null && WorldGen.SolidTile(num4, num5 + 1)) + if (!tile.active() && tile.liquid == 0 && Main.tile[x, y + 1] != null && WorldGen.SolidTile(x, y + 1)) { - Main.tile[num4, num5].frameY = 0; - Main.tile[num4, num5].slope(0); - Main.tile[num4, num5].halfBrick(false); - if (Main.tile[num4, num5 + 1].type == 0) + tile.frameY = 0; + tile.slope(0); + tile.halfBrick(false); + //On dirt blocks, there's a small chance to grow a dye plant + if (Main.tile[x, y + 1].type == TileID.Dirt) { if (Main.rand.NextBool(1000)) { - Main.tile[num4, num5].active(true); - Main.tile[num4, num5].type = 227; - Main.tile[num4, num5].frameX = (short)(34 * Main.rand.Next(1, 13)); - while (Main.tile[num4, num5].frameX == 144) + tile.active(true); + tile.type = TileID.DyePlants; + tile.frameX = (short)(34 * Main.rand.Next(1, 13)); + while (tile.frameX == 144) { - Main.tile[num4, num5].frameX = (short)(34 * Main.rand.Next(1, 13)); + tile.frameX = (short)(34 * Main.rand.Next(1, 13)); } } if (Main.netMode == NetmodeID.MultiplayerClient) { - NetMessage.SendTileSquare(-1, num4, num5, 1, TileChangeType.None); + NetMessage.SendTileSquare(-1, x, y, 1, TileChangeType.None); } } - if (Main.tile[num4, num5 + 1].type == 2) + //On grass, grow flowers + if (Main.tile[x, y + 1].type == TileID.Grass) { if (Main.rand.NextBool(2)) { - Main.tile[num4, num5].active(true); - Main.tile[num4, num5].type = 3; - Main.tile[num4, num5].frameX = (short)(18 * Main.rand.Next(6, 11)); - while (Main.tile[num4, num5].frameX == 144) + tile.active(true); + tile.type = TileID.Plants; + tile.frameX = (short)(18 * Main.rand.Next(6, 11)); + while (tile.frameX == 144) { - Main.tile[num4, num5].frameX = (short)(18 * Main.rand.Next(6, 11)); + tile.frameX = (short)(18 * Main.rand.Next(6, 11)); } } else { - Main.tile[num4, num5].active(true); - Main.tile[num4, num5].type = 73; - Main.tile[num4, num5].frameX = (short)(18 * Main.rand.Next(6, 21)); - while (Main.tile[num4, num5].frameX == 144) + tile.active(true); + tile.type = TileID.Plants2; + tile.frameX = (short)(18 * Main.rand.Next(6, 21)); + while (tile.frameX == 144) { - Main.tile[num4, num5].frameX = (short)(18 * Main.rand.Next(6, 21)); + tile.frameX = (short)(18 * Main.rand.Next(6, 21)); } } if (Main.netMode == NetmodeID.MultiplayerClient) { - NetMessage.SendTileSquare(-1, num4, num5, 1, TileChangeType.None); + NetMessage.SendTileSquare(-1, x, y, 1, TileChangeType.None); } } - else if (Main.tile[num4, num5 + 1].type == 109) + //On hallowed grass, grow hallowed flowers + else if (Main.tile[x, y + 1].type == TileID.HallowedGrass) { if (Main.rand.NextBool(2)) { - Main.tile[num4, num5].active(true); - Main.tile[num4, num5].type = 110; - Main.tile[num4, num5].frameX = (short)(18 * Main.rand.Next(4, 7)); - while (Main.tile[num4, num5].frameX == 90) + tile.active(true); + tile.type = TileID.HallowedPlants; + tile.frameX = (short)(18 * Main.rand.Next(4, 7)); + while (tile.frameX == 90) { - Main.tile[num4, num5].frameX = (short)(18 * Main.rand.Next(4, 7)); + tile.frameX = (short)(18 * Main.rand.Next(4, 7)); } } else { - Main.tile[num4, num5].active(true); - Main.tile[num4, num5].type = 113; - Main.tile[num4, num5].frameX = (short)(18 * Main.rand.Next(2, 8)); - while (Main.tile[num4, num5].frameX == 90) + tile.active(true); + tile.type = TileID.HallowedPlants2; + tile.frameX = (short)(18 * Main.rand.Next(2, 8)); + while (tile.frameX == 90) { - Main.tile[num4, num5].frameX = (short)(18 * Main.rand.Next(2, 8)); + tile.frameX = (short)(18 * Main.rand.Next(2, 8)); } } if (Main.netMode == NetmodeID.MultiplayerClient) { - NetMessage.SendTileSquare(-1, num4, num5, 1, TileChangeType.None); + NetMessage.SendTileSquare(-1, x, y, 1, TileChangeType.None); } } - else if (Main.tile[num4, num5 + 1].type == 60) + //On jungle grass, grow jungle flowers + else if (Main.tile[x, y + 1].type == TileID.JungleGrass) { - Main.tile[num4, num5].active(true); - Main.tile[num4, num5].type = 74; - Main.tile[num4, num5].frameX = (short)(18 * Main.rand.Next(9, 17)); + tile.active(true); + tile.type = TileID.JunglePlants2; + tile.frameX = (short)(18 * Main.rand.Next(9, 17)); if (Main.netMode == NetmodeID.MultiplayerClient) { - NetMessage.SendTileSquare(-1, num4, num5, 1, TileChangeType.None); + NetMessage.SendTileSquare(-1, x, y, 1, TileChangeType.None); } } } @@ -216,15 +230,15 @@ namespace CalamityMod.Items.Accessories public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Accessories/ManaOverloader.cs b/Items/Accessories/ManaOverloader.cs index ab197dddde..36950b8cc8 100644 --- a/Items/Accessories/ManaOverloader.cs +++ b/Items/Accessories/ManaOverloader.cs @@ -11,7 +11,8 @@ namespace CalamityMod.Items.Accessories DisplayName.SetDefault("Mana Polarizer"); Tooltip.SetDefault("Increases max mana by 50 and magic damage by 6%\n" + "Life regen lowered by 3 if mana is above 50% of its maximum\n" + - "Spectre healing if mana is below 10% of its maximum"); + "Grants spectre healing, the amount healed scales with your mana\n" + + "The more mana you have, the more you heal"); } public override void SetDefaults() diff --git a/Items/Accessories/StatMeter.cs b/Items/Accessories/StatMeter.cs index 36eb6d66b9..4256880aa8 100644 --- a/Items/Accessories/StatMeter.cs +++ b/Items/Accessories/StatMeter.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Accessories Item heldItem = null; if (player.selectedItem >= 0 && player.selectedItem < Main.maxInventory) - heldItem = player.inventory[player.selectedItem]; + heldItem = player.ActiveItem(); // Replace the vanilla tooltip with a full stat readout foreach (TooltipLine l in list) diff --git a/Items/Accessories/TheAmalgam.cs b/Items/Accessories/TheAmalgam.cs index 1ca24a1b49..7338190ab6 100644 --- a/Items/Accessories/TheAmalgam.cs +++ b/Items/Accessories/TheAmalgam.cs @@ -11,6 +11,7 @@ using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Accessories { @@ -18,21 +19,24 @@ namespace CalamityMod.Items.Accessories { public const int FireProjectiles = 2; public const float FireAngleSpread = 120; - public int FireCountdown = 0; + public int counter = 0; + public const int ProjectileDamage = 2000; + public const int FungalClumpDamage = 1000; + public const int AuraDamage = 300; + public bool WaterBonuses = false; public override void SetStaticDefaults() { DisplayName.SetDefault("The Amalgam"); Tooltip.SetDefault("15% increased damage\n" + - "Shade rains down when you are hit\n" + - "You will confuse nearby enemies when you are struck\n" + - "Drops brimstone fireballs from the sky occasionally\n" + - "Brimstone fire rains down while invincibility is active\n" + + "Shade and brimstone fire rain down when you are hit\n" + + "Nearby enemies receive a variety of debuffs when you are hit\n" + + "Brimstone fireballs drop from the sky occasionally\n" + + "Summons a fungal clump to fight for you that leaves behind poisonous seawater\n" + + "75% increased movement speed, 10% increase to all damage, and plus 40 defense while submerged in any liquid\n" + + "The above bonuses also apply when passing through the clump's poisonous seawater\n" + "Temporary immunity to lava, greatly reduces lava burn damage, and 15% increased damage while in lava\n" + - "Summons a fungal clump to fight for you\n" + - "You leave behind poisonous seawater as you move\n" + - "75% increased movement speed, 10% increase to all damage, and plus 40 defense while submerged in liquid\n" + - "If you are damaged while submerged in liquid you will gain a damaging aura for a short time\n" + + "You have a damaging aura that envenoms nearby enemies and increased movement in liquids\n" + "Provides heat protection in Death Mode"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(9, 6)); } @@ -47,147 +51,135 @@ namespace CalamityMod.Items.Accessories item.accessory = true; } - public override bool CanEquipAccessory(Player player, int slot) - { - CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.fungalClump) - { - return false; - } - return true; - } + public override bool CanEquipAccessory(Player player, int slot) => !player.Calamity().fungalClump; public override void UpdateAccessory(Player player, bool hideVisual) { + //Counter used for aura and Gehenna effects + counter++; + CalamityPlayer modPlayer = player.Calamity(); - modPlayer.aBrain = true; + modPlayer.amalgam = true; modPlayer.fungalClump = true; - if (player.whoAmI == Main.myPlayer) - { - if (player.FindBuffIndex(ModContent.BuffType()) == -1) - { - player.AddBuff(ModContent.BuffType(), 3600, true); - } - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), (int)(1000f * player.MinionDamage()), 1f, Main.myPlayer, 0f, 0f); - } - } - player.allDamage += 0.15f; player.ignoreWater = true; player.lavaRose = true; + player.allDamage += 0.15f; player.lavaMax += 240; if (player.lavaWet) { player.allDamage += 0.15f; } - if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) + + //emit light + Lighting.AddLight((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f), 0f, 0.5f, 1.25f); + + //Summon the Fungal Clump, ai[0] is 1f to indicate this is from the Amalgam, not the Fungal Clump + if (player.whoAmI == Main.myPlayer) + { + if (player.FindBuffIndex(BuffType()) == -1) + { + player.AddBuff(BuffType(), 3600, true); + } + if (player.ownedProjectileCounts[ProjectileType()] < 1) + { + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ProjectileType(), (int)(FungalClumpDamage * player.MinionDamage()), 1f, player.whoAmI, 1f, 0f); + } + } + + Rectangle rectangle = new Rectangle((int)(player.position.X + player.velocity.X * 0.5f - 4f), (int)(player.position.Y + player.velocity.Y * 0.5f - 4f), player.width + 8, player.height + 8); + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + if (proj.active && proj.friendly && proj.type == ProjectileType() && proj.ai[0] == 1f && proj.damage > 0) + { + Rectangle rect = proj.getRect(); + if (rectangle.Intersects(rect)) + { + WaterBonuses = true; + } + } + } + if (WaterBonuses || player.IsUnderwater()) { player.allDamage += 0.1f; player.statDefense += 40; player.moveSpeed += 0.75f; } - if ((double)player.velocity.X > 0 || (double)player.velocity.Y > 0 || (double)player.velocity.X < -0.1 || (double)player.velocity.Y < -0.1) - { - if (player.whoAmI == Main.myPlayer) - { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(2000 * player.AverageDamage()), 0f, player.whoAmI, 0f, 0f); - } - } + if (player.immune) { if (Main.rand.NextBool(20)) { if (player.whoAmI == Main.myPlayer) { - for (int l = 0; l < 1; l++) - { - float x = player.position.X + (float)Main.rand.Next(-400, 400); - float y = player.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num15 = player.position.X + (float)(player.width / 2) - vector.X; - float num16 = player.position.Y + (float)(player.height / 2) - vector.Y; - num15 += (float)Main.rand.Next(-100, 101); - int num17 = 22; - float num18 = (float)Math.Sqrt((double)(num15 * num15 + num16 * num16)); - num18 = (float)num17 / num18; - num15 *= num18; - num16 *= num18; - int type = Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType(); - 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].Calamity().forceTypeless = true; - } + float x = player.position.X + Main.rand.NextFloat(-400, 400); + float y = player.position.Y - Main.rand.NextFloat(500, 800); + Vector2 projOrigin = new Vector2(x, y); + float xDist = player.Center.X - projOrigin.X; + float yDist = player.Center.Y - projOrigin.Y; + xDist += Main.rand.NextFloat(-100, 100); + float speed = 22f; + Vector2 playerVector = new Vector2(xDist, yDist); + float playerDist = playerVector.Length(); + playerDist = speed / playerDist; + playerVector.X *= playerDist; + playerVector.Y *= playerDist; + int type = Main.rand.NextBool(2) ? ProjectileType() : ProjectileType(); + int rain = Projectile.NewProjectile(projOrigin, playerVector, type, (int)(ProjectileDamage * player.AverageDamage()), 1f, player.whoAmI, 0f, 0f); + Projectile proj = Main.projectile[rain]; + proj.tileCollide = false; + proj.usesLocalNPCImmunity = true; + proj.localNPCHitCooldown = 10; + proj.usesIDStaticNPCImmunity = false; + proj.Calamity().forceTypeless = true; } } } - int seaCounter = 0; - Lighting.AddLight((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f), 0f, 0.5f, 1.25f); - int num = BuffID.Venom; - float num2 = 300f; - bool flag = seaCounter % 60 == 0; - int num3 = (int)(320 * player.AverageDamage()); - int random = Main.rand.Next(5); + int buffType = BuffID.Venom; + float auraRange = 300f; + int auraDmg = (int)(AuraDamage * player.AverageDamage()); 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 < 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) - { - if (nPC.FindBuffIndex(num) == -1) - { - nPC.AddBuff(num, 300, false); - } - if (flag) - { - if (player.whoAmI == Main.myPlayer) - { - Projectile p = Projectile.NewProjectileDirect(nPC.Center, Vector2.Zero, ModContent.ProjectileType(), num3, 0f, player.whoAmI, l); - } - } - } - } - } - } - seaCounter++; - if (seaCounter >= 180) - { - } - if (FireCountdown == 0) - { - FireCountdown = 600; - } - if (FireCountdown > 0) - { - FireCountdown--; - if (FireCountdown == 0) - { - if (player.whoAmI == Main.myPlayer) - { - int speed2 = 25; - float spawnX = Main.rand.Next(1000) - 500 + player.Center.X; - float spawnY = -1000 + player.Center.Y; - Vector2 baseSpawn = new Vector2(spawnX, spawnY); - Vector2 baseVelocity = player.Center - baseSpawn; - baseVelocity.Normalize(); - baseVelocity *= speed2; - for (int i = 0; i < FireProjectiles; i++) - { - Vector2 spawn = baseSpawn; - 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; - Projectile.NewProjectile(spawn.X, spawn.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), (int)(2000 * player.AverageDamage()), 5f, Main.myPlayer, 0f, 0f); - } - } - } + for (int l = 0; l < Main.maxNPCs; l++) + { + NPC npc = Main.npc[l]; + if (npc.active && !npc.friendly && npc.damage > 0 && !npc.dontTakeDamage && Vector2.Distance(player.Center, npc.Center) <= auraRange) + { + if (npc.FindBuffIndex(buffType) == -1 && !npc.buffImmune[buffType]) + { + npc.AddBuff(buffType, 300, false); + } + if (counter % 30 == 0) + { + if (player.whoAmI == Main.myPlayer) + { + Projectile p = Projectile.NewProjectileDirect(npc.Center, Vector2.Zero, ProjectileType(), auraDmg, 0f, player.whoAmI, l); + } + } + } + } } + if (counter % 480 == 0) + { + if (player.whoAmI == Main.myPlayer) + { + int speed = 25; + float spawnX = Main.rand.Next(1000) - 500 + player.Center.X; + float spawnY = -1000 + player.Center.Y; + Vector2 baseSpawn = new Vector2(spawnX, spawnY); + Vector2 baseVelocity = player.Center - baseSpawn; + baseVelocity.Normalize(); + baseVelocity *= speed; + for (int i = 0; i < FireProjectiles; i++) + { + Vector2 spawn = baseSpawn; + spawn.X += i * 30 - (FireProjectiles * 15); + Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-FireAngleSpread / 2 + (FireAngleSpread * i / (float)FireProjectiles))); + velocity.X += 3 * Main.rand.NextFloat() - 1.5f; + Projectile.NewProjectile(spawn, velocity, ProjectileType(), (int)(ProjectileDamage * player.AverageDamage()), 5f, player.whoAmI, 0f, 0f); + } + } + } } public override void AddRecipes() diff --git a/Items/Accessories/TheCamper.cs b/Items/Accessories/TheCamper.cs index b7e2755d4d..0b4fac1ec4 100644 --- a/Items/Accessories/TheCamper.cs +++ b/Items/Accessories/TheCamper.cs @@ -68,13 +68,13 @@ namespace CalamityMod.Items.Accessories } } } - if (player.HeldItem != null && !player.HeldItem.IsAir && player.HeldItem.stack > 0) + if (player.ActiveItem() != null && !player.ActiveItem().IsAir && player.ActiveItem().stack > 0) { - bool summon = player.HeldItem.summon; - bool rogue = player.HeldItem.Calamity().rogue; - bool melee = player.HeldItem.melee; - bool ranged = player.HeldItem.ranged; - bool magic = player.HeldItem.magic; + bool summon = player.ActiveItem().summon; + bool rogue = player.ActiveItem().Calamity().rogue; + bool melee = player.ActiveItem().melee; + bool ranged = player.ActiveItem().ranged; + bool magic = player.ActiveItem().magic; if (summon) { player.minionKB += 0.10f; diff --git a/Items/Accessories/Wings/ElysianWings.cs b/Items/Accessories/Wings/ElysianWings.cs index b208859ac8..1de428e6b6 100644 --- a/Items/Accessories/Wings/ElysianWings.cs +++ b/Items/Accessories/Wings/ElysianWings.cs @@ -35,6 +35,7 @@ namespace CalamityMod.Items.Accessories.Wings player.moveSpeed += 0.4f; player.lavaMax += 240; player.wingTimeMax = 200; + player.noFallDmg = true; modPlayer.elysianFire = true; if (hideVisual) { diff --git a/Items/Ammo/AstralSolution.cs b/Items/Ammo/AstralSolution.cs index 22601bac44..eb11992048 100644 --- a/Items/Ammo/AstralSolution.cs +++ b/Items/Ammo/AstralSolution.cs @@ -10,7 +10,8 @@ namespace CalamityMod.Items.Ammo public override void SetStaticDefaults() { DisplayName.SetDefault("Astral Solution"); - Tooltip.SetDefault("Used by the Clentaminator.\nSpreads the Astral."); + Tooltip.SetDefault("Used by the Clentaminator\n" + + "Spreads the Astral Infection"); } public override void SetDefaults() @@ -28,7 +29,7 @@ namespace CalamityMod.Items.Ammo public override bool ConsumeAmmo(Player player) { - return !(player.itemAnimation < player.HeldItem.useAnimation - 3); + return !(player.itemAnimation < player.ActiveItem().useAnimation - 3); } } } diff --git a/Items/Armor/FathomSwarmerBreastplate.cs b/Items/Armor/FathomSwarmerBreastplate.cs index 7c4a8171c2..19963235bd 100644 --- a/Items/Armor/FathomSwarmerBreastplate.cs +++ b/Items/Armor/FathomSwarmerBreastplate.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Fathom Swarmer Breastplate"); Tooltip.SetDefault("12% increased damage reduction and minion damage\n" + - "+1 max minions\n" + + "+1 max minion\n" + "Boosted defense and regen increased while submerged in liquid\n" + "Reduces defense loss within the Abyss"); } diff --git a/Items/Armor/FathomSwarmerVisage.cs b/Items/Armor/FathomSwarmerVisage.cs index 2f67fd1faf..79848c149e 100644 --- a/Items/Armor/FathomSwarmerVisage.cs +++ b/Items/Armor/FathomSwarmerVisage.cs @@ -35,18 +35,18 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { - player.setBonus = "30% increased minion damage and +1 max minion\n" + + player.setBonus = "10% increased minion damage and +1 max minion\n" + "Grants the ability to climb walls\n" + - "10% increased minion damage while submerged in liquid\n" + + "30% increased minion damage while submerged in liquid\n" + "Provides a moderate amount of light and moderately reduces breath loss in the abyss"; CalamityPlayer modPlayer = player.Calamity(); modPlayer.fathomSwarmer = true; player.spikedBoots = 2; player.maxMinions++; - player.minionDamage += 0.3f; + player.minionDamage += 0.1f; if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) { - player.minionDamage += 0.1f; + player.minionDamage += 0.3f; } } diff --git a/Items/Armor/TarragonMask.cs b/Items/Armor/TarragonMask.cs index 1e1f9b171c..4d162d5f89 100644 --- a/Items/Armor/TarragonMask.cs +++ b/Items/Armor/TarragonMask.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Items.Armor "Increased heart pickup range\n" + "Enemies have a chance to drop extra hearts on death\n" + "On every 5th critical strike you will fire a leaf storm\n" + - "Magic projectiles have a 50% chance to heal you on enemy hits\n" + + "Magic projectiles heal you on enemy hits\n" + "Amount healed is based on projectile damage"; } diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index e3da4e2a97..30c05bdabe 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -5,6 +5,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.DifficultyItems; using CalamityMod.Items.Materials; using CalamityMod.Items.PermanentBoosters; +using CalamityMod.Items.Placeables.Furniture.Fountains; using CalamityMod.Items.Potions; using CalamityMod.Items.Tools; using CalamityMod.Items.Weapons.Magic; @@ -103,16 +104,16 @@ namespace CalamityMod.Items item.damage = (int)(item.damage * 1.25); else if (CalamityMod.twentyDamageBuffList?.Contains(item.type) ?? false) item.damage = (int)(item.damage * 1.2); - else if (item.type == ItemID.MagnetSphere) + else if (CalamityMod.tenDamageBuffList?.Contains(item.type) ?? false) item.damage = (int)(item.damage * 1.1); - else if (item.type == ItemID.Razorpine) - item.damage = (int)(item.damage * 0.95); - else if (item.type == ItemID.Phantasm) + else if (CalamityMod.tenDamageNerfList?.Contains(item.type) ?? false) item.damage = (int)(item.damage * 0.9); - else if (item.type == ItemID.LastPrism) - item.damage = (int)(item.damage * 0.85); else if (CalamityMod.quarterDamageNerfList?.Contains(item.type) ?? false) item.damage = (int)(item.damage * 0.75); + else if (item.type == ItemID.BlizzardStaff) + item.damage = (int)(item.damage * 0.7); + else if (item.type == ItemID.LaserMachinegun) + item.damage = (int)(item.damage * 0.6); else if (item.type == ItemID.StardustDragonStaff) item.damage = (int)(item.damage * 0.5); @@ -353,7 +354,7 @@ namespace CalamityMod.Items } } } - if (modPlayer.harpyWingBoost) + if (modPlayer.harpyWingBoost && modPlayer.harpyRing) { if (Main.rand.NextBool(5)) { @@ -738,7 +739,7 @@ namespace CalamityMod.Items } return false; } - if (player.HeldItem.type == ModContent.ItemType()) + if (player.ActiveItem().type == ModContent.ItemType()) { bool hasBlades = false; for (int i = 0; i < Main.projectile.Length; i++) @@ -772,7 +773,7 @@ namespace CalamityMod.Items } return false; } - if (player.HeldItem.type == ModContent.ItemType()) + if (player.ActiveItem().type == ModContent.ItemType()) { bool canContinue = true; int count = 0; @@ -2621,6 +2622,27 @@ Provides heat and cold protection in Death Mode"; } } } + + Mod fargos = ModLoader.GetMod("Fargowiltas"); + if (fargos != null) + { + //Fargo's fountain effects + if (item.type == ModContent.ItemType()) + { + TooltipLine line = new TooltipLine(mod, "Tooltip0", "Forces surrounding biome state to Sunken Sea upon activation"); + tooltips.Add(line); + } + if (item.type == ModContent.ItemType()) + { + TooltipLine line = new TooltipLine(mod, "Tooltip0", "Forces surrounding biome state to Sulphurous Sea upon activation"); + tooltips.Add(line); + } + if (item.type == ModContent.ItemType()) + { + TooltipLine line = new TooltipLine(mod, "Tooltip0", "Forces surrounding biome state to Astral upon activation"); + tooltips.Add(line); + } + } } #endregion @@ -2703,6 +2725,7 @@ Provides heat and cold protection in Death Mode"; // Queen Bee case ItemID.QueenBeeBossBag: + DropHelper.DropItem(player, ItemID.Stinger, 8, 12); DropHelper.DropItem(player, ModContent.ItemType(), 50, 75); break; @@ -2740,6 +2763,7 @@ Provides heat and cold protection in Death Mode"; float aegisChance = DropHelper.LegendaryDropRateFloat; DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.revenge, aegisChance); DropHelper.DropItem(player, ModContent.ItemType(), 8, 13); + DropHelper.DropItemChance(player, ModContent.ItemType(), DropHelper.RareVariantDropRateInt); break; // Duke Fishron @@ -2890,35 +2914,11 @@ Provides heat and cold protection in Death Mode"; #region Body if (item.type == ItemID.GladiatorBreastplate || item.type == ItemID.ObsidianShirt) player.Calamity().throwingCrit += 3; - else if (item.type == ItemID.PalladiumBreastplate) - player.Calamity().throwingCrit += 2; - else if (item.type == ItemID.CobaltBreastplate) - player.Calamity().throwingCrit += 3; - else if (item.type == ItemID.OrichalcumBreastplate) - player.Calamity().throwingCrit += 6; - else if (item.type == ItemID.TitaniumBreastplate) - player.Calamity().throwingCrit += 3; - else if (item.type == ItemID.HallowedPlateMail) - player.Calamity().throwingCrit += 7; - else if (item.type == ItemID.ChlorophytePlateMail) - player.Calamity().throwingCrit += 7; - else if (item.type == ItemID.Gi) - player.Calamity().throwingCrit += 5; #endregion #region Legs if (item.type == ItemID.GladiatorLeggings || item.type == ItemID.ObsidianPants) player.Calamity().throwingVelocity += 0.03f; - else if (item.type == ItemID.PalladiumLeggings) - player.Calamity().throwingCrit += 1; - else if (item.type == ItemID.MythrilGreaves) - player.Calamity().throwingCrit += 3; - else if (item.type == ItemID.AdamantiteLeggings) - player.Calamity().throwingCrit += 4; - else if (item.type == ItemID.TitaniumLeggings) - player.Calamity().throwingCrit += 3; - else if (item.type == ItemID.ChlorophyteGreaves) - player.Calamity().throwingCrit += 8; #endregion } #endregion @@ -2992,8 +2992,7 @@ Provides heat and cold protection in Death Mode"; } else if (item.type == ItemID.HarpyWings) { - if (modPlayer.harpyRing) - modPlayer.harpyWingBoost = true; + modPlayer.harpyWingBoost = true; player.moveSpeed += 0.3f; player.noFallDmg = true; } @@ -3201,18 +3200,6 @@ Provides heat and cold protection in Death Mode"; if (item.type == ItemID.HandWarmer) modPlayer.handWarmer = true; - if (item.type == ItemID.CelestialStone || item.type == ItemID.CelestialShell || (item.type == ItemID.MoonStone && !Main.dayTime) || - (item.type == ItemID.SunStone && Main.dayTime)) - { - player.Calamity().throwingCrit += 2; - } - if (item.type == ItemID.DestroyerEmblem) - player.Calamity().throwingCrit += 8; - if (item.type == ItemID.EyeoftheGolem) - player.Calamity().throwingCrit += 10; - if (item.type == ItemID.PutridScent) - player.Calamity().throwingCrit += 5; - // Hard / Guarding / Armored / Warding give 0.25% / 0.5% / 0.75% / 1% DR if (item.prefix == PrefixID.Hard) { @@ -3258,7 +3245,6 @@ Provides heat and cold protection in Death Mode"; player.rangedCrit -= 1; player.magicCrit -= 1; player.thrownCrit -= 1; - player.Calamity().throwingCrit += item.prefix == PrefixID.Lucky ? 3 : 1; } } #endregion @@ -3456,6 +3442,14 @@ Provides heat and cold protection in Death Mode"; public static readonly int RarityDarkBlueBuyPrice = Item.buyPrice(1, 80, 0, 0); public static readonly int RarityVioletBuyPrice = Item.buyPrice(2, 50, 0, 0); public static readonly int RarityHotPinkBuyPrice = Item.buyPrice(5, 0, 0, 0); + + //These duplicates are for my sanity... + public static readonly int Rarity12BuyPrice = Item.buyPrice(1, 20, 0, 0); + public static readonly int Rarity13BuyPrice = Item.buyPrice(1, 40, 0, 0); + public static readonly int Rarity14BuyPrice = Item.buyPrice(1, 80, 0, 0); + public static readonly int Rarity15BuyPrice = Item.buyPrice(2, 50, 0, 0); + public static readonly int Rarity16BuyPrice = Item.buyPrice(5, 0, 0, 0); + public static int GetBuyPrice(int rarity) { switch (rarity) diff --git a/Items/Dyes/AstralBlueDye.cs b/Items/Dyes/AstralBlueDye.cs new file mode 100644 index 0000000000..602f7341f4 --- /dev/null +++ b/Items/Dyes/AstralBlueDye.cs @@ -0,0 +1,36 @@ +using CalamityMod.Items.Placeables.Ores; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Dyes +{ + public class AstralBlueDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/AstralBlueDyeShader")), "DyePass"). + UseColor(new Color(109, 242, 197)).UseSecondaryColor(new Color(42, 147, 154)); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Astral Blue Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = 9; + item.value = Item.sellPrice(0, 2, 0, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/AstralBlueDye.png b/Items/Dyes/AstralBlueDye.png new file mode 100644 index 0000000000..d752cde17b Binary files /dev/null and b/Items/Dyes/AstralBlueDye.png differ diff --git a/Items/Dyes/AstralOrangeDye.cs b/Items/Dyes/AstralOrangeDye.cs new file mode 100644 index 0000000000..4945847a5e --- /dev/null +++ b/Items/Dyes/AstralOrangeDye.cs @@ -0,0 +1,36 @@ +using CalamityMod.Items.Placeables.Ores; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Dyes +{ + public class AstralOrangeDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/AstralOrangeDyeShader")), "DyePass"). + UseColor(new Color(255, 166, 94)).UseSecondaryColor(new Color(238, 93, 82)); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Astral Orange Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = 9; + item.value = Item.sellPrice(0, 2, 0, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/AstralOrangeDye.png b/Items/Dyes/AstralOrangeDye.png new file mode 100644 index 0000000000..40ead0b235 Binary files /dev/null and b/Items/Dyes/AstralOrangeDye.png differ diff --git a/Items/Dyes/AstralSwirlDye.cs b/Items/Dyes/AstralSwirlDye.cs new file mode 100644 index 0000000000..33ff3d0f06 --- /dev/null +++ b/Items/Dyes/AstralSwirlDye.cs @@ -0,0 +1,37 @@ +using CalamityMod.Items.Placeables.Ores; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Dyes +{ + public class AstralSwirlDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/AstralSwirlDyeShader")), "DyePass"). + UseColor(new Color(42, 147, 154)).UseSecondaryColor(new Color(238, 93, 82)).UseImage("Images/Misc/Perlin"); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Astral Swirl Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = 9; + item.value = Item.sellPrice(0, 3, 0, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/AstralSwirlDye.png b/Items/Dyes/AstralSwirlDye.png new file mode 100644 index 0000000000..bccd692381 Binary files /dev/null and b/Items/Dyes/AstralSwirlDye.png differ diff --git a/Items/Dyes/BaseDye.cs b/Items/Dyes/BaseDye.cs new file mode 100644 index 0000000000..65d718738e --- /dev/null +++ b/Items/Dyes/BaseDye.cs @@ -0,0 +1,42 @@ +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Dyes +{ + public abstract class BaseDye : ModItem + { + public abstract ArmorShaderData ShaderDataToBind + { + get; + } + public sealed override void SetStaticDefaults() + { + if (!Main.dedServ) + { + GameShaders.Armor.BindShader(item.type, ShaderDataToBind); + } + SafeSetStaticDefaults(); + } + public sealed override void SetDefaults() + { + byte dye = item.dye; + item.CloneDefaults(ItemID.GelDye); + item.dye = dye; + SafeSetDefaults(); + } + /// + /// Similar to SetDefaults, but always accounts for defining dye IDs + /// + public virtual void SafeSetDefaults() + { + } + /// + /// Similar to SetStaticDefaults, but always accounts for shader binding. + /// + public virtual void SafeSetStaticDefaults() + { + } + } +} \ No newline at end of file diff --git a/Items/Dyes/CeaselessDye.cs b/Items/Dyes/CeaselessDye.cs new file mode 100644 index 0000000000..c865caa946 --- /dev/null +++ b/Items/Dyes/CeaselessDye.cs @@ -0,0 +1,36 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Graphics.Shaders; + +namespace CalamityMod.Items.Dyes +{ + public class CeaselessDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/CeaselessDyeShader")), "DyePass"); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Ceaseless Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.PureGreen; + item.value = Item.sellPrice(0, 4, 0, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.VoidDye); + recipe.AddIngredient(ItemID.ShadowDye); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/CeaselessDye.png b/Items/Dyes/CeaselessDye.png new file mode 100644 index 0000000000..edaae80f09 Binary files /dev/null and b/Items/Dyes/CeaselessDye.png differ diff --git a/Items/Dyes/DefiledFlameDye.cs b/Items/Dyes/DefiledFlameDye.cs new file mode 100644 index 0000000000..96706e639b --- /dev/null +++ b/Items/Dyes/DefiledFlameDye.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Items.Dyes +{ + public class DefiledFlameDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/DefiledFlameDyeShader")), "DyePass"). + UseColor(new Color(106, 190, 48)).UseSecondaryColor(new Color(204, 248, 48)).UseImage("Images/Misc/Perlin"); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Defiled Flame Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = 4; + item.value = CalamityGlobalItem.Rarity4BuyPrice; + } + } +} \ No newline at end of file diff --git a/Items/Dyes/DefiledFlameDye.png b/Items/Dyes/DefiledFlameDye.png new file mode 100644 index 0000000000..648497ccae Binary files /dev/null and b/Items/Dyes/DefiledFlameDye.png differ diff --git a/Items/Dyes/DragonSoulDye.cs b/Items/Dyes/DragonSoulDye.cs new file mode 100644 index 0000000000..e5ff29b85c --- /dev/null +++ b/Items/Dyes/DragonSoulDye.cs @@ -0,0 +1,36 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Graphics.Shaders; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Items.Dyes +{ + public class DragonSoulDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/DragonSoulDyeShader")), "DyePass"); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Dragon Soul Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.Violet; + item.value = Item.sellPrice(0, 8, 0, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/DragonSoulDye.png b/Items/Dyes/DragonSoulDye.png new file mode 100644 index 0000000000..bdb8ff2e4d Binary files /dev/null and b/Items/Dyes/DragonSoulDye.png differ diff --git a/Items/Dyes/ElementalDye.cs b/Items/Dyes/ElementalDye.cs new file mode 100644 index 0000000000..a53145c467 --- /dev/null +++ b/Items/Dyes/ElementalDye.cs @@ -0,0 +1,38 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Dyes +{ + public class ElementalDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/ElementalDyeShader")), "DyePass").UseImage("Images/Misc/Perlin"); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Elemental Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.value = Item.sellPrice(0, 2, 50, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.SolarDye); + recipe.AddIngredient(ItemID.VortexDye); + recipe.AddIngredient(ItemID.StardustDye); + recipe.AddIngredient(ItemID.NebulaDye); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/ElementalDye.png b/Items/Dyes/ElementalDye.png new file mode 100644 index 0000000000..2308343fb6 Binary files /dev/null and b/Items/Dyes/ElementalDye.png differ diff --git a/Items/Dyes/EndothermicDye.cs b/Items/Dyes/EndothermicDye.cs new file mode 100644 index 0000000000..6630a5ac20 --- /dev/null +++ b/Items/Dyes/EndothermicDye.cs @@ -0,0 +1,37 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Graphics.Shaders; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Items.Dyes +{ + public class EndothermicDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/EndothermicDyeShader")), "DyePass"). + UseColor(new Color(123, 205, 237)).UseSecondaryColor(new Color(85, 85, 171)); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Endothermic Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.value = Item.sellPrice(0, 5, 0, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/EndothermicDye.png b/Items/Dyes/EndothermicDye.png new file mode 100644 index 0000000000..760d187983 Binary files /dev/null and b/Items/Dyes/EndothermicDye.png differ diff --git a/Items/Dyes/AdrenalineHairDye.cs b/Items/Dyes/HairDye/AdrenalineHairDye.cs similarity index 93% rename from Items/Dyes/AdrenalineHairDye.cs rename to Items/Dyes/HairDye/AdrenalineHairDye.cs index ddd5fff709..6d07db5548 100644 --- a/Items/Dyes/AdrenalineHairDye.cs +++ b/Items/Dyes/HairDye/AdrenalineHairDye.cs @@ -2,7 +2,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Items.Dyes +namespace CalamityMod.Items.Dyes.HairDye { public class AdrenalineHairDye : ModItem { diff --git a/Items/Dyes/AdrenalineHairDye.png b/Items/Dyes/HairDye/AdrenalineHairDye.png similarity index 100% rename from Items/Dyes/AdrenalineHairDye.png rename to Items/Dyes/HairDye/AdrenalineHairDye.png diff --git a/Items/Dyes/RageHairDye.cs b/Items/Dyes/HairDye/RageHairDye.cs similarity index 93% rename from Items/Dyes/RageHairDye.cs rename to Items/Dyes/HairDye/RageHairDye.cs index 3524432ada..373d925b3c 100644 --- a/Items/Dyes/RageHairDye.cs +++ b/Items/Dyes/HairDye/RageHairDye.cs @@ -2,7 +2,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Items.Dyes +namespace CalamityMod.Items.Dyes.HairDye { public class RageHairDye : ModItem { diff --git a/Items/Dyes/RageHairDye.png b/Items/Dyes/HairDye/RageHairDye.png similarity index 100% rename from Items/Dyes/RageHairDye.png rename to Items/Dyes/HairDye/RageHairDye.png diff --git a/Items/Dyes/StealthHairDye.cs b/Items/Dyes/HairDye/StealthHairDye.cs similarity index 93% rename from Items/Dyes/StealthHairDye.cs rename to Items/Dyes/HairDye/StealthHairDye.cs index c9b96417a9..ef877f9d33 100644 --- a/Items/Dyes/StealthHairDye.cs +++ b/Items/Dyes/HairDye/StealthHairDye.cs @@ -2,7 +2,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Items.Dyes +namespace CalamityMod.Items.Dyes.HairDye { public class StealthHairDye : ModItem { diff --git a/Items/Dyes/StealthHairDye.png b/Items/Dyes/HairDye/StealthHairDye.png similarity index 100% rename from Items/Dyes/StealthHairDye.png rename to Items/Dyes/HairDye/StealthHairDye.png diff --git a/Items/Dyes/WingTimeHairDye.cs b/Items/Dyes/HairDye/WingTimeHairDye.cs similarity index 93% rename from Items/Dyes/WingTimeHairDye.cs rename to Items/Dyes/HairDye/WingTimeHairDye.cs index b2d2bad5a2..7f77cefa55 100644 --- a/Items/Dyes/WingTimeHairDye.cs +++ b/Items/Dyes/HairDye/WingTimeHairDye.cs @@ -2,7 +2,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Items.Dyes +namespace CalamityMod.Items.Dyes.HairDye { public class WingTimeHairDye : ModItem { diff --git a/Items/Dyes/WingTimeHairDye.png b/Items/Dyes/HairDye/WingTimeHairDye.png similarity index 100% rename from Items/Dyes/WingTimeHairDye.png rename to Items/Dyes/HairDye/WingTimeHairDye.png diff --git a/Items/Dyes/NightmareDye.cs b/Items/Dyes/NightmareDye.cs new file mode 100644 index 0000000000..9807c284bb --- /dev/null +++ b/Items/Dyes/NightmareDye.cs @@ -0,0 +1,37 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Graphics.Shaders; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Items.Dyes +{ + public class NightmareDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/NightmareDyeShader")), "DyePass"). + UseColor(new Color(249, 81, 0)).UseSecondaryColor(new Color(255, 203, 106)); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Nightmare Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.value = Item.sellPrice(0, 5, 0, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/NightmareDye.png b/Items/Dyes/NightmareDye.png new file mode 100644 index 0000000000..93a142281b Binary files /dev/null and b/Items/Dyes/NightmareDye.png differ diff --git a/Items/Dyes/ReaverDye.cs b/Items/Dyes/ReaverDye.cs new file mode 100644 index 0000000000..80379e10db --- /dev/null +++ b/Items/Dyes/ReaverDye.cs @@ -0,0 +1,37 @@ +using CalamityMod.Items.Placeables.Ores; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent.Dyes; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Dyes +{ + public class ReaverDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/ReaverDyeShader")), "DyePass"). + UseColor(new Color(54, 164, 66)).UseSecondaryColor(new Color(224, 115, 65)); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Reaver Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = 7; + item.value = Item.sellPrice(0, 1, 0, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/ReaverDye.png b/Items/Dyes/ReaverDye.png new file mode 100644 index 0000000000..aa8d35dd5c Binary files /dev/null and b/Items/Dyes/ReaverDye.png differ diff --git a/Items/Dyes/ShadowspecDye.cs b/Items/Dyes/ShadowspecDye.cs new file mode 100644 index 0000000000..03e6b1997f --- /dev/null +++ b/Items/Dyes/ShadowspecDye.cs @@ -0,0 +1,37 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Graphics.Shaders; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Items.Dyes +{ + public class ShadowspecDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/ShadowspecDyeShader")), "DyePass"). + UseColor(new Color(46, 27, 60)).UseSecondaryColor(new Color(132, 142, 191)).UseImage("Images/Misc/Perlin"); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Shadowspec Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.Developer; + item.value = Item.sellPrice(0, 10, 0, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/ShadowspecDye.png b/Items/Dyes/ShadowspecDye.png new file mode 100644 index 0000000000..e323537ca9 Binary files /dev/null and b/Items/Dyes/ShadowspecDye.png differ diff --git a/Items/Dyes/StratusDye.cs b/Items/Dyes/StratusDye.cs new file mode 100644 index 0000000000..f7e57b0be3 --- /dev/null +++ b/Items/Dyes/StratusDye.cs @@ -0,0 +1,39 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Graphics.Shaders; +using Microsoft.Xna.Framework; +using CalamityMod.Items.Placeables.Ores; + +namespace CalamityMod.Items.Dyes +{ + public class StratusDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/StratusDyeShader")), "DyePass"). + UseColor(new Color(36, 86, 163)).UseSecondaryColor(new Color(124, 204, 223)).UseImage("Images/Misc/Perlin"); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Stratus Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.PureGreen; + item.value = Item.sellPrice(0, 4, 50, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/StratusDye.png b/Items/Dyes/StratusDye.png new file mode 100644 index 0000000000..c46981da43 Binary files /dev/null and b/Items/Dyes/StratusDye.png differ diff --git a/Items/Materials/DepthCells.png b/Items/Materials/DepthCells.png index 1475b534ef..75d3fe54a6 100644 Binary files a/Items/Materials/DepthCells.png and b/Items/Materials/DepthCells.png differ diff --git a/Items/Materials/Lumenite.png b/Items/Materials/Lumenite.png index 012625eb5d..b67689835f 100644 Binary files a/Items/Materials/Lumenite.png and b/Items/Materials/Lumenite.png differ diff --git a/Items/Placeables/Furniture/Fountains/AbyssFountainItem.cs b/Items/Placeables/Furniture/Fountains/AbyssFountainItem.cs new file mode 100644 index 0000000000..f1f018affe --- /dev/null +++ b/Items/Placeables/Furniture/Fountains/AbyssFountainItem.cs @@ -0,0 +1,30 @@ +using Terraria; +using Terraria.ModLoader; +using CalamityMod.Tiles.Furniture.Fountains; + +namespace CalamityMod.Items.Placeables.Furniture.Fountains +{ + public class AbyssFountainItem : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Abyss Water Fountain"); + } + + public override void SetDefaults() + { + item.width = 22; + item.height = 42; + item.maxStack = 999; + item.useTurn = true; + item.autoReuse = true; + item.useAnimation = 15; + item.useTime = 10; + item.useStyle = 1; + item.consumable = true; + item.value = Item.buyPrice(0, 4, 0, 0); + item.rare = 0; + item.createTile = ModContent.TileType(); + } + } +} diff --git a/Items/Placeables/Furniture/Fountains/AbyssFountainItem.png b/Items/Placeables/Furniture/Fountains/AbyssFountainItem.png new file mode 100644 index 0000000000..2b82813299 Binary files /dev/null and b/Items/Placeables/Furniture/Fountains/AbyssFountainItem.png differ diff --git a/Items/Placeables/Furniture/Fountains/AstralFountainItem.cs b/Items/Placeables/Furniture/Fountains/AstralFountainItem.cs new file mode 100644 index 0000000000..7891da5667 --- /dev/null +++ b/Items/Placeables/Furniture/Fountains/AstralFountainItem.cs @@ -0,0 +1,30 @@ +using Terraria; +using Terraria.ModLoader; +using CalamityMod.Tiles.Furniture.Fountains; + +namespace CalamityMod.Items.Placeables.Furniture.Fountains +{ + public class AstralFountainItem : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Water Fountain"); + } + + public override void SetDefaults() + { + item.width = 22; + item.height = 42; + item.maxStack = 999; + item.useTurn = true; + item.autoReuse = true; + item.useAnimation = 15; + item.useTime = 10; + item.useStyle = 1; + item.consumable = true; + item.value = Item.buyPrice(0, 4, 0, 0); + item.rare = 0; + item.createTile = ModContent.TileType(); + } + } +} diff --git a/Items/Placeables/Furniture/Fountains/AstralFountainItem.png b/Items/Placeables/Furniture/Fountains/AstralFountainItem.png new file mode 100644 index 0000000000..b206cf12fb Binary files /dev/null and b/Items/Placeables/Furniture/Fountains/AstralFountainItem.png differ diff --git a/Items/Placeables/Furniture/Fountains/SulphurousFountainItem.cs b/Items/Placeables/Furniture/Fountains/SulphurousFountainItem.cs new file mode 100644 index 0000000000..78316ac7b4 --- /dev/null +++ b/Items/Placeables/Furniture/Fountains/SulphurousFountainItem.cs @@ -0,0 +1,30 @@ +using Terraria; +using Terraria.ModLoader; +using CalamityMod.Tiles.Furniture.Fountains; + +namespace CalamityMod.Items.Placeables.Furniture.Fountains +{ + public class SulphurousFountainItem : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sulphuric Water Fountain"); + } + + public override void SetDefaults() + { + item.width = 22; + item.height = 42; + item.maxStack = 999; + item.useTurn = true; + item.autoReuse = true; + item.useAnimation = 15; + item.useTime = 10; + item.useStyle = 1; + item.consumable = true; + item.value = Item.buyPrice(0, 4, 0, 0); + item.rare = 0; + item.createTile = ModContent.TileType(); + } + } +} diff --git a/Items/Placeables/Furniture/Fountains/SulphurousFountainItem.png b/Items/Placeables/Furniture/Fountains/SulphurousFountainItem.png new file mode 100644 index 0000000000..138609c239 Binary files /dev/null and b/Items/Placeables/Furniture/Fountains/SulphurousFountainItem.png differ diff --git a/Items/Placeables/Furniture/Fountains/SunkenSeaFountain.cs b/Items/Placeables/Furniture/Fountains/SunkenSeaFountain.cs new file mode 100644 index 0000000000..82099e5799 --- /dev/null +++ b/Items/Placeables/Furniture/Fountains/SunkenSeaFountain.cs @@ -0,0 +1,30 @@ +using Terraria; +using Terraria.ModLoader; +using CalamityMod.Tiles.Furniture.Fountains; + +namespace CalamityMod.Items.Placeables.Furniture.Fountains +{ + public class SunkenSeaFountain : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sunken Water Fountain"); + } + + public override void SetDefaults() + { + item.width = 26; + item.height = 32; + item.maxStack = 999; + item.useTurn = true; + item.autoReuse = true; + item.useAnimation = 15; + item.useTime = 10; + item.useStyle = 1; + item.consumable = true; + item.value = Item.buyPrice(0, 4, 0, 0); + item.rare = 0; + item.createTile = ModContent.TileType(); + } + } +} diff --git a/Items/Placeables/Furniture/Fountains/SunkenSeaFountain.png b/Items/Placeables/Furniture/Fountains/SunkenSeaFountain.png new file mode 100644 index 0000000000..a4dbce972b Binary files /dev/null and b/Items/Placeables/Furniture/Fountains/SunkenSeaFountain.png differ diff --git a/Items/SummonItems/BossRush.cs b/Items/SummonItems/BossRush.cs index 12caa05aa5..21c2f2b616 100644 --- a/Items/SummonItems/BossRush.cs +++ b/Items/SummonItems/BossRush.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.SummonItems Tooltip.SetDefault("A ritualistic artifact, thought to have brought upon The End many millennia ago\n" + "Sealed away in the abyss, far from those that would seek to misuse it\n" + "Activates Boss Rush Mode, using it again will deactivate Boss Rush Mode\n" + - "During the Boss Rush, all wires, wired devices, and mounts will be disabled"); + "During the Boss Rush, all wires and wired devices will be disabled"); } public override void SetDefaults() diff --git a/Items/TreasureBags/AstrumDeusBag.cs b/Items/TreasureBags/AstrumDeusBag.cs index 162485bbd1..67c8777c76 100644 --- a/Items/TreasureBags/AstrumDeusBag.cs +++ b/Items/TreasureBags/AstrumDeusBag.cs @@ -38,6 +38,8 @@ namespace CalamityMod.Items.TreasureBags return true; } + public override void PostUpdate() => CalamityUtils.ForceItemIntoWorld(item); + public override void OpenBossBag(Player player) { player.TryGettingDevArmor(); @@ -55,10 +57,7 @@ namespace CalamityMod.Items.TreasureBags DropHelper.DropItemChance(player, ModContent.ItemType(), DropHelper.RareVariantDropRateInt); // Equipment - float f = Main.rand.NextFloat(); - bool replaceWithRare = f <= DropHelper.RareVariantDropRateFloat; // 1/40 chance of getting Hide of Astrum Deus - DropHelper.DropItemCondition(player, ModContent.ItemType(), !replaceWithRare); - DropHelper.DropItemCondition(player, ModContent.ItemType(), replaceWithRare); + DropHelper.DropItemRIV(player, ModContent.ItemType(), ModContent.ItemType(), 1f, DropHelper.RareVariantDropRateFloat); // Vanity DropHelper.DropItemChance(player, ModContent.ItemType(), 7); diff --git a/Items/TreasureBags/DesertScourgeBag.cs b/Items/TreasureBags/DesertScourgeBag.cs index 28c0e48905..d832044afa 100644 --- a/Items/TreasureBags/DesertScourgeBag.cs +++ b/Items/TreasureBags/DesertScourgeBag.cs @@ -51,13 +51,7 @@ namespace CalamityMod.Items.TreasureBags DropHelper.DropItemChance(player, ModContent.ItemType(), 3); DropHelper.DropItemChance(player, ModContent.ItemType(), 3); DropHelper.DropItemChance(player, ModContent.ItemType(), 3); - float f = Main.rand.NextFloat(); - bool replaceWithRare = f <= DropHelper.RareVariantDropRateFloat; // 1/40 chance overall of getting Dune Hopper - if (f < 0.3333f) // 1/3 chance of getting Scourge of the Desert OR Dune Hopper replacing it - { - DropHelper.DropItemCondition(player, ModContent.ItemType(), !replaceWithRare); - DropHelper.DropItemCondition(player, ModContent.ItemType(), replaceWithRare); - } + DropHelper.DropItemRIV(player, ModContent.ItemType(), ModContent.ItemType(), 0.3333f, DropHelper.RareVariantDropRateFloat); // Equipment DropHelper.DropItem(player, ModContent.ItemType()); diff --git a/Items/TreasureBags/DevourerofGodsBag.cs b/Items/TreasureBags/DevourerofGodsBag.cs index 0373012409..d81ea77596 100644 --- a/Items/TreasureBags/DevourerofGodsBag.cs +++ b/Items/TreasureBags/DevourerofGodsBag.cs @@ -49,6 +49,8 @@ namespace CalamityMod.Items.TreasureBags return true; } + public override void PostUpdate() => CalamityUtils.ForceItemIntoWorld(item); + public override void OpenBossBag(Player player) { player.TryGettingDevArmor(); diff --git a/Items/TreasureBags/PlaguebringerGoliathBag.cs b/Items/TreasureBags/PlaguebringerGoliathBag.cs index 7fc7c68c57..7e0b0982a3 100644 --- a/Items/TreasureBags/PlaguebringerGoliathBag.cs +++ b/Items/TreasureBags/PlaguebringerGoliathBag.cs @@ -10,6 +10,7 @@ using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.PlaguebringerGoliath; using CalamityMod.World; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.TreasureBags @@ -34,10 +35,7 @@ namespace CalamityMod.Items.TreasureBags item.expert = true; } - public override bool CanRightClick() - { - return true; - } + public override bool CanRightClick() => true; public override void OpenBossBag(Player player) { @@ -45,6 +43,7 @@ namespace CalamityMod.Items.TreasureBags // Materials DropHelper.DropItem(player, ModContent.ItemType(), 13, 17); + DropHelper.DropItem(player, ItemID.Stinger, 4, 8); // Weapons DropHelper.DropItemChance(player, ModContent.ItemType(), 3); // Virulence diff --git a/Items/TreasureBags/StarterBag.cs b/Items/TreasureBags/StarterBag.cs index 73156c9ba8..aaa86fe5ac 100644 --- a/Items/TreasureBags/StarterBag.cs +++ b/Items/TreasureBags/StarterBag.cs @@ -1,4 +1,4 @@ - +using CalamityMod.Items.Pets; using CalamityMod.Items.DifficultyItems; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; @@ -24,10 +24,7 @@ namespace CalamityMod.Items.TreasureBags item.rare = 1; } - public override bool CanRightClick() - { - return true; - } + public override bool CanRightClick() => true; public override void RightClick(Player player) { @@ -54,13 +51,16 @@ namespace CalamityMod.Items.TreasureBags DropHelper.DropItem(player, ItemID.Torch, 25); DropHelper.DropItem(player, ItemID.Chest, 3); - // Difficulty items - DropHelper.DropItem(player, ModContent.ItemType()); - DropHelper.DropItem(player, ModContent.ItemType()); + // Difficulty items (doesn't drop in Normal) + DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.expertMode); + DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.expertMode); // Speedrun King Slime DropHelper.DropItem(player, ItemID.SlimeCrown); + // The Lad + DropHelper.DropItemCondition(player, ModContent.ItemType(), player.name == "Aleksh" || player.name == "Shark Lad"); + // Music box (if music mod installed) Mod musicMod = ModLoader.GetMod("CalamityModMusic"); if (musicMod != null) diff --git a/Items/Weapons/DraedonsArsenal/GatlingLaser.cs b/Items/Weapons/DraedonsArsenal/GatlingLaser.cs index 95ba01c964..c5ac8b9fe2 100644 --- a/Items/Weapons/DraedonsArsenal/GatlingLaser.cs +++ b/Items/Weapons/DraedonsArsenal/GatlingLaser.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/DraedonsArsenal/LaserRifle.cs b/Items/Weapons/DraedonsArsenal/LaserRifle.cs index f4dda677e9..38bbd2e6b6 100644 --- a/Items/Weapons/DraedonsArsenal/LaserRifle.cs +++ b/Items/Weapons/DraedonsArsenal/LaserRifle.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal item.useAmmo = AmmoID.Bullet; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Vector2 velocity = new Vector2(speedX, speedY); if (velocity.Length() > 5f) diff --git a/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs b/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs index d2c56e9d06..e3d9745c97 100644 --- a/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs +++ b/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return base.CanUseItem(player); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Vector2 velocity = new Vector2(speedX, speedY); if (velocity.Length() > 5f) diff --git a/Items/Weapons/DraedonsArsenal/PulseRifle.cs b/Items/Weapons/DraedonsArsenal/PulseRifle.cs index 9b25a662ec..afd41b0476 100644 --- a/Items/Weapons/DraedonsArsenal/PulseRifle.cs +++ b/Items/Weapons/DraedonsArsenal/PulseRifle.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal item.useAmmo = AmmoID.Bullet; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Vector2 velocity = new Vector2(speedX, speedY); if (velocity.Length() > 5f) diff --git a/Items/Weapons/DraedonsArsenal/TeslaCannon.cs b/Items/Weapons/DraedonsArsenal/TeslaCannon.cs index 5dbe7c8bbb..91aec7d77a 100644 --- a/Items/Weapons/DraedonsArsenal/TeslaCannon.cs +++ b/Items/Weapons/DraedonsArsenal/TeslaCannon.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal item.useAmmo = AmmoID.Bullet; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Vector2 velocity = new Vector2(speedX, speedY); if (velocity.Length() > 5f) diff --git a/Items/Weapons/Magic/ApoctosisArray.cs b/Items/Weapons/Magic/ApoctosisArray.cs index 73720a1bcd..12c8980faf 100644 --- a/Items/Weapons/Magic/ApoctosisArray.cs +++ b/Items/Weapons/Magic/ApoctosisArray.cs @@ -12,15 +12,16 @@ namespace CalamityMod.Items.Weapons.Magic { DisplayName.SetDefault("Apoctosis Array"); Tooltip.SetDefault("Fires ion blasts that speed up and then explode\n" + - "The higher your mana the more damage they will do"); + "The higher your mana the more damage they will do\n" + + "Astral steroids can inhibit the potential of this weapon"); } public override void SetDefaults() { item.width = 98; - item.damage = 58; + item.damage = 45; item.magic = true; - item.mana = 12; + item.mana = 14; item.useAnimation = 7; item.useTime = 7; item.useStyle = 5; @@ -45,7 +46,8 @@ namespace CalamityMod.Items.Weapons.Magic { float manaAmount = (float)player.statMana * 0.01f; float damageMult = manaAmount; - int projectile = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, (int)((double)damage * damageMult), knockBack, player.whoAmI, 0.0f, 0.0f); + float injectionNerf = player.Calamity().astralInjection ? 0.6f : 1f; + int projectile = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, (int)(damage * damageMult * injectionNerf), knockBack, player.whoAmI, 0f, 0f); Main.projectile[projectile].scale = manaAmount * 0.375f; return false; } diff --git a/Items/Weapons/Magic/AquamarineStaff.cs b/Items/Weapons/Magic/AquamarineStaff.cs index 310d688085..ffcd12cb7b 100644 --- a/Items/Weapons/Magic/AquamarineStaff.cs +++ b/Items/Weapons/Magic/AquamarineStaff.cs @@ -38,10 +38,10 @@ namespace CalamityMod.Items.Weapons.Magic public override Vector2? HoldoutOrigin() { - return new Vector2(15, 15); + return new Vector2(10, 10); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { int num6 = Main.rand.Next(2, 3); for (int index = 0; index < num6; ++index) diff --git a/Items/Weapons/Magic/CalamitasInferno.cs b/Items/Weapons/Magic/CalamitasInferno.cs index 4dcc74056d..3a185591b2 100644 --- a/Items/Weapons/Magic/CalamitasInferno.cs +++ b/Items/Weapons/Magic/CalamitasInferno.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 88; + item.damage = 65; item.magic = true; item.mana = 20; item.width = 28; diff --git a/Items/Weapons/Magic/CrystalFlareStaff.cs b/Items/Weapons/Magic/CrystalFlareStaff.cs index f77cc32a6a..443bde8a77 100644 --- a/Items/Weapons/Magic/CrystalFlareStaff.cs +++ b/Items/Weapons/Magic/CrystalFlareStaff.cs @@ -18,18 +18,18 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 30; + item.damage = 50; item.magic = true; item.mana = 15; item.width = 44; item.height = 46; - item.useTime = 12; - item.useAnimation = 24; + item.useTime = 10; + item.useAnimation = 20; item.useStyle = 5; item.noMelee = true; item.knockBack = 5.25f; - item.value = Item.buyPrice(0, 36, 0, 0); - item.rare = 5; + item.value = Item.buyPrice(0, 60, 0, 0); + item.rare = 7; item.UseSound = SoundID.Item20; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); @@ -44,8 +44,9 @@ namespace CalamityMod.Items.Weapons.Magic public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 3); - recipe.AddIngredient(ItemID.CrystalShard, 15); + recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ItemID.FrostCore); recipe.AddIngredient(ItemID.FrostStaff); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); diff --git a/Items/Weapons/Magic/DarkSpark.cs b/Items/Weapons/Magic/DarkSpark.cs index c1d7c22130..12d3301906 100644 --- a/Items/Weapons/Magic/DarkSpark.cs +++ b/Items/Weapons/Magic/DarkSpark.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -42,7 +43,7 @@ namespace CalamityMod.Items.Weapons.Magic public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0.0f, 0.0f); return false; diff --git a/Items/Weapons/Magic/DarkSpark.png b/Items/Weapons/Magic/DarkSpark.png index df1fa170eb..b082a2a1f4 100644 Binary files a/Items/Weapons/Magic/DarkSpark.png and b/Items/Weapons/Magic/DarkSpark.png differ diff --git a/Items/Weapons/Magic/Downpour.cs b/Items/Weapons/Magic/Downpour.cs index b946a7036c..4451a7543b 100644 --- a/Items/Weapons/Magic/Downpour.cs +++ b/Items/Weapons/Magic/Downpour.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Weapons.Magic return new Vector2(10, 10); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0.0f, 0.0f); return false; diff --git a/Items/Weapons/Magic/Effervescence.cs b/Items/Weapons/Magic/Effervescence.cs index 5976f683fd..147a521634 100644 --- a/Items/Weapons/Magic/Effervescence.cs +++ b/Items/Weapons/Magic/Effervescence.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -20,8 +21,8 @@ namespace CalamityMod.Items.Weapons.Magic item.mana = 17; item.width = 56; item.height = 26; - item.useTime = 12; - item.useAnimation = 12; + item.useTime = 15; + item.useAnimation = 15; item.useStyle = 5; item.noMelee = true; item.knockBack = 3.75f; @@ -34,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Magic item.Calamity().customRarity = CalamityRarity.Turquoise; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { for (int randomBullets = 0; randomBullets <= 4; randomBullets++) { diff --git a/Items/Weapons/Magic/GhastlyVisage.cs b/Items/Weapons/Magic/GhastlyVisage.cs index d380e2445d..777ab102c0 100644 --- a/Items/Weapons/Magic/GhastlyVisage.cs +++ b/Items/Weapons/Magic/GhastlyVisage.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Items.Weapons.Magic spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Items/Weapons/Magic/GhastlyVisageGlow"), item.Center - Main.screenPosition, null, Color.White, rotation, origin, 1f, SpriteEffects.None, 0f); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Magic/Hematemesis.cs b/Items/Weapons/Magic/Hematemesis.cs index 85e32cc9ae..d9bebc5370 100644 --- a/Items/Weapons/Magic/Hematemesis.cs +++ b/Items/Weapons/Magic/Hematemesis.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Weapons.Magic return new Vector2(15, 15); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { position = Main.MouseWorld; for (int x = 0; x < 10; x++) diff --git a/Items/Weapons/Magic/Lazhar.cs b/Items/Weapons/Magic/Lazhar.cs index c0ccf26346..9e9eff4ef5 100644 --- a/Items/Weapons/Magic/Lazhar.cs +++ b/Items/Weapons/Magic/Lazhar.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -33,7 +34,7 @@ namespace CalamityMod.Items.Weapons.Magic item.shoot = ModContent.ProjectileType(); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { float SpeedX = speedX + (float)Main.rand.Next(-15, 16) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-15, 16) * 0.05f; @@ -45,6 +46,7 @@ namespace CalamityMod.Items.Weapons.Magic { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.HeatRay); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ItemID.FragmentSolar, 10); recipe.AddIngredient(ItemID.ChlorophyteBar, 6); recipe.AddTile(TileID.LunarCraftingStation); diff --git a/Items/Weapons/Magic/LightGodsBrilliance.cs b/Items/Weapons/Magic/LightGodsBrilliance.cs index b25236887d..c844846ad9 100644 --- a/Items/Weapons/Magic/LightGodsBrilliance.cs +++ b/Items/Weapons/Magic/LightGodsBrilliance.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -35,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Magic item.Calamity().customRarity = CalamityRarity.Dedicated; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { int num6 = Main.rand.Next(2, 5); for (int index = 0; index < num6; ++index) diff --git a/Items/Weapons/Magic/MadAlchemistsCocktailGlove.cs b/Items/Weapons/Magic/MadAlchemistsCocktailGlove.cs index cdfdce12c8..e17ace5fba 100644 --- a/Items/Weapons/Magic/MadAlchemistsCocktailGlove.cs +++ b/Items/Weapons/Magic/MadAlchemistsCocktailGlove.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -55,7 +56,7 @@ namespace CalamityMod.Items.Weapons.Magic return base.CanUseItem(player); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { if (player.altFunctionUse == 2) { diff --git a/Items/Weapons/Magic/MagneticMeltdown.cs b/Items/Weapons/Magic/MagneticMeltdown.cs index 46fe27a1bc..77556128fd 100644 --- a/Items/Weapons/Magic/MagneticMeltdown.cs +++ b/Items/Weapons/Magic/MagneticMeltdown.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Magic return new Vector2(15, 15); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { for (int index = 0; index < 4; ++index) { diff --git a/Items/Weapons/Magic/Mistlestorm.cs b/Items/Weapons/Magic/Mistlestorm.cs index ea864b3ab4..3871950373 100644 --- a/Items/Weapons/Magic/Mistlestorm.cs +++ b/Items/Weapons/Magic/Mistlestorm.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Magic return new Vector2(15, 15); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { int num106 = 2 + Main.rand.Next(3); for (int num107 = 0; num107 < num106; num107++) diff --git a/Items/Weapons/Magic/PrimordialEarth.cs b/Items/Weapons/Magic/PrimordialEarth.cs index b072a3b452..97dfe1b26a 100644 --- a/Items/Weapons/Magic/PrimordialEarth.cs +++ b/Items/Weapons/Magic/PrimordialEarth.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 85; + item.damage = 60; item.magic = true; item.mana = 19; item.width = 30; diff --git a/Items/Weapons/Magic/Purge.cs b/Items/Weapons/Magic/Purge.cs index fb62663478..5c9108e9ca 100644 --- a/Items/Weapons/Magic/Purge.cs +++ b/Items/Weapons/Magic/Purge.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -47,7 +48,7 @@ namespace CalamityMod.Items.Weapons.Magic recipe.AddRecipe(); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Magic/RecitationoftheBeast.cs b/Items/Weapons/Magic/RecitationoftheBeast.cs index 20e93320d7..fb150cfe9d 100644 --- a/Items/Weapons/Magic/RecitationoftheBeast.cs +++ b/Items/Weapons/Magic/RecitationoftheBeast.cs @@ -1,5 +1,6 @@ using CalamityMod.Projectiles.Magic; using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ID; @@ -39,7 +40,7 @@ namespace CalamityMod.Items.Weapons.Magic item.Calamity().customRarity = CalamityRarity.DarkBlue; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { float spread = 60f * 0.0174f; double startAngle = Math.Atan2(speedX, speedY) - spread / 2; diff --git a/Items/Weapons/Magic/ShadecrystalTome.cs b/Items/Weapons/Magic/ShadecrystalTome.cs index 3a6e52a8ff..52e676c48b 100644 --- a/Items/Weapons/Magic/ShadecrystalTome.cs +++ b/Items/Weapons/Magic/ShadecrystalTome.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -34,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Magic item.shootSpeed = 16f; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { int num6 = Main.rand.Next(1, 3); for (int index = 0; index < num6; ++index) diff --git a/Items/Weapons/Magic/ShiftingSands.cs b/Items/Weapons/Magic/ShiftingSands.cs index 93fb96a13c..6882e3429a 100644 --- a/Items/Weapons/Magic/ShiftingSands.cs +++ b/Items/Weapons/Magic/ShiftingSands.cs @@ -16,14 +16,14 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 95; + item.damage = 85; item.magic = true; item.channel = true; item.mana = 20; item.width = 58; item.height = 58; - item.useTime = 18; - item.useAnimation = 18; + item.useTime = 30; + item.useAnimation = 30; item.useStyle = 1; item.noMelee = true; item.knockBack = 5f; @@ -32,6 +32,7 @@ namespace CalamityMod.Items.Weapons.Magic item.UseSound = SoundID.Item20; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 7f; + item.autoReuse = true; } public override void AddRecipes() diff --git a/Items/Weapons/Magic/StormSpray.cs b/Items/Weapons/Magic/StormSpray.cs index 0865a9b195..1d39ed22ff 100644 --- a/Items/Weapons/Magic/StormSpray.cs +++ b/Items/Weapons/Magic/StormSpray.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Weapons.Magic return new Vector2(10, 10); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0.0f, 0.0f); return false; diff --git a/Items/Weapons/Magic/T1000.cs b/Items/Weapons/Magic/T1000.cs index 314379819f..b76bc6e8d1 100644 --- a/Items/Weapons/Magic/T1000.cs +++ b/Items/Weapons/Magic/T1000.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -49,7 +50,7 @@ namespace CalamityMod.Items.Weapons.Magic recipe.AddRecipe(); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0.0f, 0.0f); return false; diff --git a/Items/Weapons/Magic/TearsofHeaven.cs b/Items/Weapons/Magic/TearsofHeaven.cs index 8260868d13..f919aca926 100644 --- a/Items/Weapons/Magic/TearsofHeaven.cs +++ b/Items/Weapons/Magic/TearsofHeaven.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -16,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 72; + item.damage = 64; item.magic = true; item.mana = 18; item.width = 28; @@ -34,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Magic item.shootSpeed = 5.5f; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { int num6 = Main.rand.Next(2, 3); for (int index = 0; index < num6; ++index) diff --git a/Items/Weapons/Magic/TerraRay.cs b/Items/Weapons/Magic/TerraRay.cs index 031da444c2..b61f0556ac 100644 --- a/Items/Weapons/Magic/TerraRay.cs +++ b/Items/Weapons/Magic/TerraRay.cs @@ -18,13 +18,13 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 85; + item.damage = 50; item.magic = true; item.mana = 10; item.width = 54; item.height = 54; - item.useTime = 20; - item.useAnimation = 20; + item.useTime = 24; + item.useAnimation = 24; item.useStyle = 5; item.noMelee = true; item.knockBack = 4f; @@ -45,12 +45,14 @@ namespace CalamityMod.Items.Weapons.Magic { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 7); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 7); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); diff --git a/Items/Weapons/Magic/ThornBlossom.cs b/Items/Weapons/Magic/ThornBlossom.cs index fdace77015..84a18c02f6 100644 --- a/Items/Weapons/Magic/ThornBlossom.cs +++ b/Items/Weapons/Magic/ThornBlossom.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Magic return new Vector2(15, 15); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { player.statLife -= 5; if (player.statLife <= 0) diff --git a/Items/Weapons/Magic/ValkyrieRay.cs b/Items/Weapons/Magic/ValkyrieRay.cs new file mode 100644 index 0000000000..095e5705b7 --- /dev/null +++ b/Items/Weapons/Magic/ValkyrieRay.cs @@ -0,0 +1,62 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Magic +{ + public class ValkyrieRay : ModItem + { + // The base use time of the weapon is 47: 28 charge frames + 19 cooldown frames. + // The rate at which it progresses through its charge and discharge cycle is dynamically sped up by reforges. + // This math is handled in its holdout projectile, ValkyrieRayStaff. + public const int ChargeFrames = 28; + public const int CooldownFrames = 19; + public const float GemDistance = 18f; + public static readonly Color LightColor = new Color(235, 40, 121); + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Valkyrie Ray"); + Tooltip.SetDefault("Casts a devastating ray of holy power"); + Item.staff[item.type] = true; + } + + public override void SetDefaults() + { + item.width = 54; + item.height = 52; + item.damage = 73; + item.knockBack = 8.5f; + item.magic = true; + item.mana = 26; + item.useTime = ChargeFrames + CooldownFrames; + item.useAnimation = ChargeFrames + CooldownFrames; + item.useStyle = 5; + item.UseSound = SoundID.NPCDeath7; + item.useTurn = false; + item.noMelee = true; + item.noUseGraphic = true; + item.value = Item.buyPrice(gold: 36); + item.rare = 5; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 25f; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.HallowedBar, 12); + recipe.AddIngredient(ModContent.ItemType(), 6); + recipe.AddIngredient(ItemID.Ruby); + recipe.AddIngredient(ItemID.SoulofSight); + recipe.AddIngredient(ItemID.SoulofMight); + recipe.AddIngredient(ItemID.SoulofFright); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Magic/ValkyrieRay.png b/Items/Weapons/Magic/ValkyrieRay.png new file mode 100644 index 0000000000..18ec195aa0 Binary files /dev/null and b/Items/Weapons/Magic/ValkyrieRay.png differ diff --git a/Items/Weapons/Magic/Waywasher.cs b/Items/Weapons/Magic/Waywasher.cs index b9d608533f..6ff0f3baab 100644 --- a/Items/Weapons/Magic/Waywasher.cs +++ b/Items/Weapons/Magic/Waywasher.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -33,7 +34,7 @@ namespace CalamityMod.Items.Weapons.Magic item.shootSpeed = 12f; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { float SpeedX = speedX + (float)Main.rand.Next(-20, 21) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-20, 21) * 0.05f; diff --git a/Items/Weapons/Magic/Wingman.cs b/Items/Weapons/Magic/Wingman.cs index 79654df9c4..6edfcd2e38 100644 --- a/Items/Weapons/Magic/Wingman.cs +++ b/Items/Weapons/Magic/Wingman.cs @@ -1,3 +1,4 @@ +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -14,13 +15,13 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 54; + item.damage = 49; item.magic = true; item.mana = 12; item.width = 42; item.height = 22; - item.useTime = 12; - item.useAnimation = 12; + item.useTime = 15; + item.useAnimation = 15; item.useStyle = 5; item.noMelee = true; item.knockBack = 3f; @@ -32,10 +33,10 @@ namespace CalamityMod.Items.Weapons.Magic item.shoot = ProjectileID.LaserMachinegunLaser; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - int num6 = 3; - for (int index = 0; index < num6; ++index) + int beamAmt = 3; + for (int index = 0; index < beamAmt; ++index) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); } diff --git a/Items/Weapons/Magic/WintersFury.cs b/Items/Weapons/Magic/WintersFury.cs index 507186bdd0..b69736bc4f 100644 --- a/Items/Weapons/Magic/WintersFury.cs +++ b/Items/Weapons/Magic/WintersFury.cs @@ -17,13 +17,13 @@ namespace CalamityMod.Items.Weapons.Magic } public override void SetDefaults() { - item.damage = 69; + item.damage = 59; item.magic = true; item.mana = 7; item.width = 28; item.height = 30; - item.useTime = 9; - item.useAnimation = 9; + item.useTime = 12; + item.useAnimation = 12; item.useStyle = 5; item.useTurn = false; item.noMelee = true; diff --git a/Items/Weapons/Magic/Zapper.cs b/Items/Weapons/Magic/Zapper.cs index 77dfe80b5f..33808b6d71 100644 --- a/Items/Weapons/Magic/Zapper.cs +++ b/Items/Weapons/Magic/Zapper.cs @@ -16,24 +16,36 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 40; + item.damage = 55; item.magic = true; item.mana = 4; item.width = 46; item.height = 22; - item.useTime = 10; - item.useAnimation = 10; + item.useTime = 7; + item.useAnimation = 7; item.useStyle = 5; item.noMelee = true; item.knockBack = 2f; - item.value = Item.buyPrice(0, 36, 0, 0); - item.rare = 5; + item.value = Item.buyPrice(0, 48, 0, 0); + item.rare = 6; item.UseSound = SoundID.Item12; item.autoReuse = true; item.shoot = ProjectileID.PurpleLaser; item.shootSpeed = 20f; } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + if (Main.rand.NextBool(2)) + { + type = ProjectileID.GreenLaser; + } + int laser = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); + Main.projectile[laser].usesLocalNPCImmunity = true; + Main.projectile[laser].localNPCHitCooldown = 10; + return false; + } + public override Vector2? HoldoutOffset() { return new Vector2(-5, 0); @@ -45,6 +57,9 @@ namespace CalamityMod.Items.Weapons.Magic recipe.AddIngredient(ItemID.SpaceGun); recipe.AddIngredient(ItemID.LaserRifle); recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ItemID.SoulofSight); + recipe.AddIngredient(ItemID.SoulofMight); + recipe.AddIngredient(ItemID.SoulofFright); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Melee/AegisBlade.cs b/Items/Weapons/Melee/AegisBlade.cs index 8bf4f7a002..0ad7576f0c 100644 --- a/Items/Weapons/Melee/AegisBlade.cs +++ b/Items/Weapons/Melee/AegisBlade.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), (int)(damage * 0.85), knockBack, player.whoAmI, 0f, 0f); return false; } @@ -78,12 +78,12 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), knockback, Main.myPlayer); + Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), knockback, Main.myPlayer); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), item.knockBack, Main.myPlayer); + Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), item.knockBack, Main.myPlayer); } } } diff --git a/Items/Weapons/Melee/ArkoftheCosmos.cs b/Items/Weapons/Melee/ArkoftheCosmos.cs index 1c0cb4657f..d36fddba5a 100644 --- a/Items/Weapons/Melee/ArkoftheCosmos.cs +++ b/Items/Weapons/Melee/ArkoftheCosmos.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 102; - item.damage = 500; + item.damage = 501; item.melee = true; item.useAnimation = 15; item.useTime = 15; diff --git a/Items/Weapons/Melee/AstralScythe.cs b/Items/Weapons/Melee/AstralScythe.cs index 51794a157a..90852c6093 100644 --- a/Items/Weapons/Melee/AstralScythe.cs +++ b/Items/Weapons/Melee/AstralScythe.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -33,6 +34,12 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 5f; } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, (int)(damage * 0.6), knockBack, player.whoAmI, 0f, 0f); + return false; + } + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); diff --git a/Items/Weapons/Melee/BrinyBaron.cs b/Items/Weapons/Melee/BrinyBaron.cs index 7c09cf78f8..4cf4b19886 100644 --- a/Items/Weapons/Melee/BrinyBaron.cs +++ b/Items/Weapons/Melee/BrinyBaron.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 62; - item.damage = 80; + item.damage = 75; item.melee = true; item.useAnimation = 20; item.useTime = 20; diff --git a/Items/Weapons/Melee/CorpusAvertorMelee.cs b/Items/Weapons/Melee/CorpusAvertorMelee.cs index 768a0e7aa4..01a9f3d804 100644 --- a/Items/Weapons/Melee/CorpusAvertorMelee.cs +++ b/Items/Weapons/Melee/CorpusAvertorMelee.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Hybrid; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -41,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Melee flat += lifeAmount * 0.2f * player.meleeDamage; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Melee/CosmicDischarge.cs b/Items/Weapons/Melee/CosmicDischarge.cs index 55ba0008b4..781b5bec93 100644 --- a/Items/Weapons/Melee/CosmicDischarge.cs +++ b/Items/Weapons/Melee/CosmicDischarge.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -38,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Melee item.Calamity().customRarity = CalamityRarity.ItemSpecific; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { float ai3 = (Main.rand.NextFloat() - 0.75f) * 0.7853982f; //0.5 Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, ai3); diff --git a/Items/Weapons/Melee/CrescentMoon.cs b/Items/Weapons/Melee/CrescentMoon.cs index 3b266c61d3..20211d1cd5 100644 --- a/Items/Weapons/Melee/CrescentMoon.cs +++ b/Items/Weapons/Melee/CrescentMoon.cs @@ -1,6 +1,7 @@ using CalamityMod.Projectiles.Melee; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -38,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Melee item.shoot = ModContent.ProjectileType(); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { float ai3 = (Main.rand.NextFloat() - 0.5f) * 0.7853982f; //0.5 Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, ai3); diff --git a/Items/Weapons/Melee/DevilsDevastation.cs b/Items/Weapons/Melee/DevilsDevastation.cs index 00dcf3f830..42740edf13 100644 --- a/Items/Weapons/Melee/DevilsDevastation.cs +++ b/Items/Weapons/Melee/DevilsDevastation.cs @@ -41,12 +41,13 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - for (int j = -8; j <= 8; j += 8) + int index = 8; + for (int j = -index; j <= index; j += index) { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(j)); - int demon = Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI, 0.0f, 0.0f); - Main.projectile[demon].penetrate = 1; + Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI, 0.0f, 0.0f); } + float num72 = item.shootSpeed; Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; diff --git a/Items/Weapons/Melee/DevilsSunrise.cs b/Items/Weapons/Melee/DevilsSunrise.cs index e0efd6d5f8..d47472a4fe 100644 --- a/Items/Weapons/Melee/DevilsSunrise.cs +++ b/Items/Weapons/Melee/DevilsSunrise.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -40,7 +41,7 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 24f; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); diff --git a/Items/Weapons/Melee/ExoGladius.cs b/Items/Weapons/Melee/ExoGladius.cs index 2410ebe1e9..ae76d02137 100644 --- a/Items/Weapons/Melee/ExoGladius.cs +++ b/Items/Weapons/Melee/ExoGladius.cs @@ -104,7 +104,7 @@ namespace CalamityMod.Items.Weapons.Melee num16 *= num18; if (player.whoAmI == Main.myPlayer) { - Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), 15f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), 15f, player.whoAmI, 0f, 0f); } } @@ -144,7 +144,7 @@ namespace CalamityMod.Items.Weapons.Melee num16 *= num18; if (player.whoAmI == Main.myPlayer) { - Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), 15f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), 15f, player.whoAmI, 0f, 0f); } } } diff --git a/Items/Weapons/Melee/FlameScytheMelee.cs b/Items/Weapons/Melee/FlameScytheMelee.cs index 3d88b310f4..5ded2dbf1f 100644 --- a/Items/Weapons/Melee/FlameScytheMelee.cs +++ b/Items/Weapons/Melee/FlameScytheMelee.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 50; - item.damage = 100; + item.damage = 90; item.noMelee = true; item.noUseGraphic = true; item.autoReuse = true; diff --git a/Items/Weapons/Melee/FlameburstShortsword.cs b/Items/Weapons/Melee/FlameburstShortsword.cs index 4344dbd2b9..1065f8462f 100644 --- a/Items/Weapons/Melee/FlameburstShortsword.cs +++ b/Items/Weapons/Melee/FlameburstShortsword.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Items.Weapons.Melee { if (target.life <= (target.lifeMax * 0.5f)) { - int boom = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), knockback, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + int boom = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), knockback, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); Main.projectile[boom].Calamity().forceMelee = true; } } @@ -62,7 +62,7 @@ namespace CalamityMod.Items.Weapons.Melee { if (target.statLife <= (target.statLifeMax2 * 0.5f)) { - int boom = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), item.knockBack, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + int boom = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), item.knockBack, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); Main.projectile[boom].Calamity().forceMelee = true; } } diff --git a/Items/Weapons/Melee/ForbiddenOathblade.cs b/Items/Weapons/Melee/ForbiddenOathblade.cs index 2dbd3a7f1a..5bdae7c940 100644 --- a/Items/Weapons/Melee/ForbiddenOathblade.cs +++ b/Items/Weapons/Melee/ForbiddenOathblade.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Melee item.height = 76; item.value = Item.buyPrice(0, 36, 0, 0); item.rare = 5; - item.shoot = ModContent.ProjectileType(); + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 3f; } diff --git a/Items/Weapons/Melee/FulgurationHalberd.cs b/Items/Weapons/Melee/FulgurationHalberd.cs index 3dcb5c06b6..016a11e406 100644 --- a/Items/Weapons/Melee/FulgurationHalberd.cs +++ b/Items/Weapons/Melee/FulgurationHalberd.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Projectiles.Melee.Spears; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -59,7 +60,7 @@ namespace CalamityMod.Items.Weapons.Melee return base.CanUseItem(player); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Melee/GaelsGreatsword.cs b/Items/Weapons/Melee/GaelsGreatsword.cs index 6869251532..09d39e5921 100644 --- a/Items/Weapons/Melee/GaelsGreatsword.cs +++ b/Items/Weapons/Melee/GaelsGreatsword.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Gael's Greatsword"); - Tooltip.SetDefault("Give me that thing, your dark soul\n" + + Tooltip.SetDefault("Hand it over, that thing. Your dark soul.\n" + "First swing fires homing skulls\n" + "Second swing fires a giant, powerful skull\n" + "Third swing deals massive damage\n" + @@ -100,7 +100,7 @@ namespace CalamityMod.Items.Weapons.Melee Projectile.NewProjectile(p.ToWorldCoordinates(8f, 0f), Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); } } - if (player.itemAnimation == (int)((double)player.itemAnimationMax * 0.5)) + if (player.itemAnimation == (int)(player.itemAnimationMax * 0.5)) { player.Calamity().gaelSwipes++; if (player.statLife <= player.statLifeMax2 * 0.5f) diff --git a/Items/Weapons/Melee/HellfireFlamberge.cs b/Items/Weapons/Melee/HellfireFlamberge.cs index bd81d77d35..1423a1a1a6 100644 --- a/Items/Weapons/Melee/HellfireFlamberge.cs +++ b/Items/Weapons/Melee/HellfireFlamberge.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 58; - item.damage = 102; + item.damage = 90; item.melee = true; item.useAnimation = 20; item.useStyle = 1; @@ -41,6 +41,7 @@ namespace CalamityMod.Items.Weapons.Melee { float SpeedX = speedX + (float)Main.rand.Next(-40, 41) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-40, 41) * 0.05f; + float damageMult = 0.5f; switch (index) { case 0: @@ -51,11 +52,12 @@ namespace CalamityMod.Items.Weapons.Melee break; case 2: type = ModContent.ProjectileType(); + damageMult = 0.75f; break; default: break; } - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)(damage * damageMult), knockBack, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Melee/HellionFlowerSpear.cs b/Items/Weapons/Melee/HellionFlowerSpear.cs index 6b8e85471c..c261d3e6e6 100644 --- a/Items/Weapons/Melee/HellionFlowerSpear.cs +++ b/Items/Weapons/Melee/HellionFlowerSpear.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 64; - item.damage = 120; + item.damage = 135; item.melee = true; item.noMelee = true; item.useTurn = true; diff --git a/Items/Weapons/Melee/KelvinCatalystMelee.cs b/Items/Weapons/Melee/KelvinCatalystMelee.cs index 98acc894be..4141e27668 100644 --- a/Items/Weapons/Melee/KelvinCatalystMelee.cs +++ b/Items/Weapons/Melee/KelvinCatalystMelee.cs @@ -5,6 +5,7 @@ using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Projectiles.Hybrid; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -40,7 +41,7 @@ namespace CalamityMod.Items.Weapons.Melee item.Calamity().customRarity = CalamityRarity.Dedicated; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Melee/LionHeart.cs b/Items/Weapons/Melee/LionHeart.cs new file mode 100644 index 0000000000..83c22f596b --- /dev/null +++ b/Items/Weapons/Melee/LionHeart.cs @@ -0,0 +1,101 @@ +using CalamityMod.Projectiles.Ranged; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + public class LionHeart : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Lion Heart"); + Tooltip.SetDefault("Summons an energy explosion on enemy hits\n" + + "Right click to summon an energy shell for a few seconds that halves all damage sources\n" + + "This has a 45 second cooldown"); + } + + public override void SetDefaults() + { + item.width = 60; + item.height = 62; + + item.damage = 700; + item.knockBack = 5.5f; + item.useStyle = 1; + item.useAnimation = 15; + item.useTime = 15; + item.shootSpeed = 0f; + + item.melee = true; + item.useTurn = true; + item.autoReuse = true; + item.UseSound = SoundID.Item1; + + item.value = CalamityGlobalItem.Rarity13BuyPrice; + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.Dedicated; + } + + public override bool AltFunctionUse(Player player) => true; + + public override bool CanUseItem(Player player) + { + if (player.altFunctionUse == 2) + { + item.shoot = ModContent.ProjectileType(); + } + else + { + item.shoot = 0; + } + return base.CanUseItem(player); + } + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + if (player.altFunctionUse == 2) + { + if (!player.Calamity().energyShellCooldown && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) + { + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); + } + } + return false; + } + + public override bool? CanHitNPC(Player player, NPC target) + { + if (player.altFunctionUse == 2) + { + return false; + } + return null; + } + + public override bool CanHitPvp(Player player, Player target) => player.altFunctionUse != 2; + + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) + { + int explosion = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), knockback, player.whoAmI, 0f, 0f); + Main.projectile[explosion].Calamity().forceMelee = true; + } + + public override void OnHitPvp(Player player, Player target, int damage, bool crit) + { + int explosion = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), item.knockBack, player.whoAmI, 0f, 0f); + Main.projectile[explosion].Calamity().forceMelee = true; + } + + public override void MeleeEffects(Player player, Rectangle hitbox) + { + if (Main.rand.NextBool(3)) + { + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 132); + } + } + } +} diff --git a/Items/Weapons/Melee/LionHeart.png b/Items/Weapons/Melee/LionHeart.png new file mode 100644 index 0000000000..c3ed56d78b Binary files /dev/null and b/Items/Weapons/Melee/LionHeart.png differ diff --git a/Items/Weapons/Melee/MirrorBlade.cs b/Items/Weapons/Melee/MirrorBlade.cs index 9cba7693da..1714a27389 100644 --- a/Items/Weapons/Melee/MirrorBlade.cs +++ b/Items/Weapons/Melee/MirrorBlade.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -36,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Melee item.Calamity().customRarity = CalamityRarity.PureGreen; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Melee/Mourningstar.cs b/Items/Weapons/Melee/Mourningstar.cs index 5b68f062c5..b225ad82c4 100644 --- a/Items/Weapons/Melee/Mourningstar.cs +++ b/Items/Weapons/Melee/Mourningstar.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -49,7 +50,7 @@ namespace CalamityMod.Items.Weapons.Melee recipe.AddRecipe(); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { float ai3 = (Main.rand.NextFloat() - 0.75f) * 0.7853982f; //0.5 float ai3X = (Main.rand.NextFloat() - 0.25f) * 0.7853982f; //0.5 diff --git a/Items/Weapons/Melee/Nebulash.cs b/Items/Weapons/Melee/Nebulash.cs index 59e78b632a..8bd1bc30e5 100644 --- a/Items/Weapons/Melee/Nebulash.cs +++ b/Items/Weapons/Melee/Nebulash.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -17,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee { item.width = 16; item.height = 16; - item.damage = 54; + item.damage = 60; item.rare = 7; item.noMelee = true; item.noUseGraphic = true; @@ -34,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Melee item.shoot = ModContent.ProjectileType(); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { float ai3 = (Main.rand.NextFloat() - 0.5f) * 0.7853982f; //0.5 Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, ai3); diff --git a/Items/Weapons/Melee/RedtideSword.cs b/Items/Weapons/Melee/RedtideSword.cs index fbc46fa451..98b7af3eb5 100644 --- a/Items/Weapons/Melee/RedtideSword.cs +++ b/Items/Weapons/Melee/RedtideSword.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -33,7 +34,7 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 6f; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage / 2, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Melee/Roxcalibur.cs b/Items/Weapons/Melee/Roxcalibur.cs index 3154f080e3..243fe4e424 100644 --- a/Items/Weapons/Melee/Roxcalibur.cs +++ b/Items/Weapons/Melee/Roxcalibur.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { - item.damage = 100; + item.damage = 80; item.knockBack = 13; item.crit += 8; item.melee = true; diff --git a/Items/Weapons/Melee/RoyalKnivesMelee.cs b/Items/Weapons/Melee/RoyalKnivesMelee.cs index 9abe8467c3..c502b927d9 100644 --- a/Items/Weapons/Melee/RoyalKnivesMelee.cs +++ b/Items/Weapons/Melee/RoyalKnivesMelee.cs @@ -1,5 +1,5 @@ using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Hybrid; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using System; @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Melee item.height = 20; item.value = Item.buyPrice(5, 0, 0, 0); item.rare = 10; - item.shoot = ModContent.ProjectileType(); + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 9f; item.Calamity().customRarity = CalamityRarity.Developer; } @@ -93,7 +93,8 @@ namespace CalamityMod.Items.Weapons.Melee num149 *= num80; float x4 = vector2.X; float y4 = vector2.Y; - Projectile.NewProjectile(x4, y4, num148, num149, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + int knife = Projectile.NewProjectile(x4, y4, num148, num149, type, damage, knockBack, player.whoAmI, 0f, 0f); + Main.projectile[knife].Calamity().forceMelee = true; } return false; } diff --git a/Items/Weapons/Melee/SoulEdge.cs b/Items/Weapons/Melee/SoulEdge.cs index 313f6f4a40..8705a97247 100644 --- a/Items/Weapons/Melee/SoulEdge.cs +++ b/Items/Weapons/Melee/SoulEdge.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -34,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Melee item.Calamity().customRarity = CalamityRarity.PureGreen; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { int num6 = Main.rand.Next(2, 4); for (int index = 0; index < num6; ++index) diff --git a/Items/Weapons/Melee/StellarStriker.cs b/Items/Weapons/Melee/StellarStriker.cs index 2374549080..b9f097c495 100644 --- a/Items/Weapons/Melee/StellarStriker.cs +++ b/Items/Weapons/Melee/StellarStriker.cs @@ -83,7 +83,7 @@ namespace CalamityMod.Items.Weapons.Melee num79 *= num80; float num114 = num78; float num115 = num79 + (float)Main.rand.Next(-80, 81) * 0.02f; - int proj = Projectile.NewProjectile(vector2.X, vector2.Y, num114, num115, 645, (int)(item.damage * (player.allDamage + player.meleeDamage - 1f) * 0.5), knockback, i, 0f, (float)Main.rand.Next(3)); + int proj = Projectile.NewProjectile(vector2.X, vector2.Y, num114, num115, ProjectileID.LunarFlare, (int)(item.damage * player.MeleeDamage() * 0.5), knockback, i, 0f, (float)Main.rand.Next(3)); Main.projectile[proj].Calamity().forceMelee = true; } } @@ -134,7 +134,7 @@ namespace CalamityMod.Items.Weapons.Melee num79 *= num80; float num114 = num78; float num115 = num79 + (float)Main.rand.Next(-80, 81) * 0.02f; - int proj = Projectile.NewProjectile(vector2.X, vector2.Y, num114, num115, 645, (int)(item.damage * (player.allDamage + player.meleeDamage - 1f) * 0.5), item.knockBack, i, 0f, (float)Main.rand.Next(3)); + int proj = Projectile.NewProjectile(vector2.X, vector2.Y, num114, num115, ProjectileID.LunarFlare, (int)(item.damage * player.MeleeDamage() * 0.5), item.knockBack, i, 0f, (float)Main.rand.Next(3)); Main.projectile[proj].Calamity().forceMelee = true; } } diff --git a/Items/Weapons/Melee/TemporalFloeSword.cs b/Items/Weapons/Melee/TemporalFloeSword.cs index e9af5c160b..339acd5767 100644 --- a/Items/Weapons/Melee/TemporalFloeSword.cs +++ b/Items/Weapons/Melee/TemporalFloeSword.cs @@ -14,13 +14,14 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Temporal Floe Sword"); Tooltip.SetDefault("The iceman cometh...\n" + - "Fires a frozen sword beam"); + "Fires a frozen sword beam that splits into two more beams\n" + + "The direction of the beams depends on in game time"); } public override void SetDefaults() { item.width = 52; - item.damage = 85; + item.damage = 95; item.melee = true; item.useAnimation = 16; item.useStyle = 1; @@ -36,6 +37,12 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 16f; } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, (int)(damage * 0.65), knockBack, player.whoAmI, 0f, 0f); + return false; + } + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); diff --git a/Items/Weapons/Melee/TrueForbiddenOathblade.cs b/Items/Weapons/Melee/TrueForbiddenOathblade.cs index b420bf771e..d303f9216a 100644 --- a/Items/Weapons/Melee/TrueForbiddenOathblade.cs +++ b/Items/Weapons/Melee/TrueForbiddenOathblade.cs @@ -31,13 +31,14 @@ namespace CalamityMod.Items.Weapons.Melee item.height = 78; item.value = Item.buyPrice(0, 80, 0, 0); item.rare = 8; - item.shoot = ModContent.ProjectileType(); + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 3f; } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - for (int i = -8; i <= 8; i += 8) + int index = 8; + for (int i = -index; i <= index; i += index) { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage / 2, knockBack, player.whoAmI, 0f, 0f); diff --git a/Items/Weapons/Melee/TruePaladinsHammerMelee.cs b/Items/Weapons/Melee/TruePaladinsHammerMelee.cs index 22f27ca5af..63838e1415 100644 --- a/Items/Weapons/Melee/TruePaladinsHammerMelee.cs +++ b/Items/Weapons/Melee/TruePaladinsHammerMelee.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 14; - item.damage = 101; + item.damage = 81; item.noMelee = true; item.noUseGraphic = true; item.autoReuse = true; diff --git a/Items/Weapons/Melee/VirulentKatana.cs b/Items/Weapons/Melee/VirulentKatana.cs index 3cd73e7d04..b5a69bb3a9 100644 --- a/Items/Weapons/Melee/VirulentKatana.cs +++ b/Items/Weapons/Melee/VirulentKatana.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -33,6 +34,12 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 9f; } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, (int)(damage * 0.85), knockBack, player.whoAmI, 0f, 0f); + return false; + } + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 240); diff --git a/Items/Weapons/Melee/YateveoBloom.cs b/Items/Weapons/Melee/YateveoBloom.cs index 4851938639..8f81f86c68 100644 --- a/Items/Weapons/Melee/YateveoBloom.cs +++ b/Items/Weapons/Melee/YateveoBloom.cs @@ -1,5 +1,6 @@ using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Melee.Spears; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -72,7 +73,7 @@ namespace CalamityMod.Items.Weapons.Melee return base.CanUseItem(player); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { if (player.altFunctionUse == 2) Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); diff --git a/Items/Weapons/Ranged/Arbalest.cs b/Items/Weapons/Ranged/Arbalest.cs index dbb5d98e0b..67cb7532f5 100644 --- a/Items/Weapons/Ranged/Arbalest.cs +++ b/Items/Weapons/Ranged/Arbalest.cs @@ -1,3 +1,4 @@ +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -34,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.Calamity().customRarity = CalamityRarity.RareVariant; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { for (int i = 0; i < 3; i++) { diff --git a/Items/Weapons/Ranged/Barinade.cs b/Items/Weapons/Ranged/Barinade.cs index 3b9a7de80b..8d74533b68 100644 --- a/Items/Weapons/Ranged/Barinade.cs +++ b/Items/Weapons/Ranged/Barinade.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -39,7 +40,7 @@ namespace CalamityMod.Items.Weapons.Ranged this.SetTag("bow"); }*/ - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Ranged/Barinautical.cs b/Items/Weapons/Ranged/Barinautical.cs index a88256fb59..63539ad4f4 100644 --- a/Items/Weapons/Ranged/Barinautical.cs +++ b/Items/Weapons/Ranged/Barinautical.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -34,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.useAmmo = 40; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Ranged/BarracudaGun.cs b/Items/Weapons/Ranged/BarracudaGun.cs index 3d2a370d39..7af724d86d 100644 --- a/Items/Weapons/Ranged/BarracudaGun.cs +++ b/Items/Weapons/Ranged/BarracudaGun.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 76; + item.damage = 63; item.channel = true; item.ranged = true; item.width = 54; @@ -43,12 +43,11 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - int num6 = Main.rand.Next(2, 3); - for (int index = 0; index < num6; ++index) + for (int index = 0; index < 2; ++index) { float SpeedX = speedX + (float)Main.rand.Next(-10, 11) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-10, 11) * 0.05f; - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)(double)damage, knockBack, player.whoAmI, 0.0f, 0.0f); + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0f, 0f); } return false; } @@ -58,6 +57,7 @@ namespace CalamityMod.Items.Weapons.Ranged ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.PiranhaGun); recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddIngredient(ItemID.SharkFin, 2); recipe.AddTile(TileID.MythrilAnvil); diff --git a/Items/Weapons/Ranged/BladedgeGreatbow.cs b/Items/Weapons/Ranged/BladedgeGreatbow.cs index 2405f2697a..c783cf4763 100644 --- a/Items/Weapons/Ranged/BladedgeGreatbow.cs +++ b/Items/Weapons/Ranged/BladedgeGreatbow.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 22; + item.damage = 25; item.ranged = true; item.width = 74; item.height = 24; diff --git a/Items/Weapons/Ranged/BlossomFlux.cs b/Items/Weapons/Ranged/BlossomFlux.cs index e3b38044c0..efe3e790f5 100644 --- a/Items/Weapons/Ranged/BlossomFlux.cs +++ b/Items/Weapons/Ranged/BlossomFlux.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -59,7 +60,7 @@ namespace CalamityMod.Items.Weapons.Ranged return base.CanUseItem(player); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { if (player.altFunctionUse == 2) { diff --git a/Items/Weapons/Ranged/ChickenCannon.cs b/Items/Weapons/Ranged/ChickenCannon.cs index eaf9543241..3f238644d6 100644 --- a/Items/Weapons/Ranged/ChickenCannon.cs +++ b/Items/Weapons/Ranged/ChickenCannon.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Weapons.Ranged return new Vector2(-10, 0); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Ranged/ClockGatlignum.cs b/Items/Weapons/Ranged/ClockGatlignum.cs index 609b3ee952..3963e48f50 100644 --- a/Items/Weapons/Ranged/ClockGatlignum.cs +++ b/Items/Weapons/Ranged/ClockGatlignum.cs @@ -1,3 +1,4 @@ +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -16,13 +17,13 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 60; + item.damage = 55; item.ranged = true; item.width = 66; item.height = 34; - item.useTime = 2; - item.reuseDelay = 10; - item.useAnimation = 6; + item.useTime = 3; + item.reuseDelay = 12; + item.useAnimation = 9; item.useStyle = 5; item.noMelee = true; item.knockBack = 3.75f; @@ -44,7 +45,7 @@ namespace CalamityMod.Items.Weapons.Ranged { float SpeedX = speedX + (float)Main.rand.Next(-15, 16) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-15, 16) * 0.05f; - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, 242, damage, knockBack, player.whoAmI, 0.0f, 0.0f); + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ProjectileID.BulletHighVelocity, damage, knockBack, player.whoAmI, 0.0f, 0.0f); return false; } @@ -60,7 +61,7 @@ namespace CalamityMod.Items.Weapons.Ranged ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.Gatligator); recipe.AddIngredient(ItemID.VenusMagnum); - recipe.AddIngredient(ItemID.HallowedBar, 5); + recipe.AddIngredient(ModContent.ItemType(), 3); recipe.AddIngredient(ItemID.Ectoplasm, 5); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); diff --git a/Items/Weapons/Ranged/Contagion.cs b/Items/Weapons/Ranged/Contagion.cs index 37fad3b6a0..a807100e39 100644 --- a/Items/Weapons/Ranged/Contagion.cs +++ b/Items/Weapons/Ranged/Contagion.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -49,7 +50,7 @@ namespace CalamityMod.Items.Weapons.Ranged recipe.AddRecipe(); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0.0f, 0.0f); return false; diff --git a/Items/Weapons/Ranged/CorrodedCaustibow.cs b/Items/Weapons/Ranged/CorrodedCaustibow.cs index 4a3fd3eec9..748e92202f 100644 --- a/Items/Weapons/Ranged/CorrodedCaustibow.cs +++ b/Items/Weapons/Ranged/CorrodedCaustibow.cs @@ -1,5 +1,6 @@ using CalamityMod.Projectiles.Ranged; using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -35,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.useAmmo = 40; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Ranged/CosmicBolter.cs b/Items/Weapons/Ranged/CosmicBolter.cs index b4b2dab7fc..1a3ebea417 100644 --- a/Items/Weapons/Ranged/CosmicBolter.cs +++ b/Items/Weapons/Ranged/CosmicBolter.cs @@ -17,12 +17,12 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 45; + item.damage = 35; item.ranged = true; item.width = 40; item.height = 76; - item.useTime = 19; - item.useAnimation = 19; + item.useTime = 20; + item.useAnimation = 20; item.useStyle = 5; item.noMelee = true; item.knockBack = 2.75f; diff --git a/Items/Weapons/Ranged/CursedCapper.cs b/Items/Weapons/Ranged/CursedCapper.cs index 60432e1d28..d8e224cffa 100644 --- a/Items/Weapons/Ranged/CursedCapper.cs +++ b/Items/Weapons/Ranged/CursedCapper.cs @@ -1,3 +1,4 @@ +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -14,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 24; + item.damage = 35; item.ranged = true; item.width = 44; item.height = 32; @@ -32,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.useAmmo = 97; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ProjectileID.CursedBullet, damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Ranged/FetidEmesis.cs b/Items/Weapons/Ranged/FetidEmesis.cs index cd034864dc..92462ddbf0 100644 --- a/Items/Weapons/Ranged/FetidEmesis.cs +++ b/Items/Weapons/Ranged/FetidEmesis.cs @@ -51,8 +51,12 @@ namespace CalamityMod.Items.Weapons.Ranged dust.velocity = Vector2.Normalize(new Vector2(speedX, speedY)).RotatedByRandom(MathHelper.ToRadians(15f)); dust.noGravity = true; } - // WoF vomit sound. - Main.PlaySound(SoundID.NPCKilled, position, 13); + if (player.Calamity().soundCooldown <= 0) + { + // WoF vomit sound. + Main.PlaySound(SoundID.NPCKilled, (int)position.X, (int)position.Y, 13, 0.5f, 0f); + player.Calamity().soundCooldown = 120; + } return false; } return true; diff --git a/Items/Weapons/Ranged/FirestormCannon.cs b/Items/Weapons/Ranged/FirestormCannon.cs index 66688140de..fda0b30f0f 100644 --- a/Items/Weapons/Ranged/FirestormCannon.cs +++ b/Items/Weapons/Ranged/FirestormCannon.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Items.Weapons.Ranged return base.CanUseItem(player); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { if (player.altFunctionUse == 2) { diff --git a/Items/Weapons/Ranged/FlakKraken.cs b/Items/Weapons/Ranged/FlakKraken.cs index 633c0a71c1..8986adf70c 100644 --- a/Items/Weapons/Ranged/FlakKraken.cs +++ b/Items/Weapons/Ranged/FlakKraken.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables; using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -38,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Ranged/Hellborn.cs b/Items/Weapons/Ranged/Hellborn.cs index d2d838fdf8..5653451a36 100644 --- a/Items/Weapons/Ranged/Hellborn.cs +++ b/Items/Weapons/Ranged/Hellborn.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Ranged return new Vector2(-5, 0); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { for (int index = 0; index < 3; ++index) { diff --git a/Items/Weapons/Ranged/Helstorm.cs b/Items/Weapons/Ranged/Helstorm.cs index 141b5ea9f3..5dc282e178 100644 --- a/Items/Weapons/Ranged/Helstorm.cs +++ b/Items/Weapons/Ranged/Helstorm.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Ranged return new Vector2(-5, 0); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { for (int index = 0; index < 2; ++index) { diff --git a/Items/Weapons/Ranged/LeadWizard.cs b/Items/Weapons/Ranged/LeadWizard.cs index dcaa615f70..8c8aff1999 100644 --- a/Items/Weapons/Ranged/LeadWizard.cs +++ b/Items/Weapons/Ranged/LeadWizard.cs @@ -16,14 +16,14 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 70; + item.damage = 58; item.crit += 30; item.ranged = true; item.width = 66; item.height = 34; - item.useTime = 2; - item.reuseDelay = 10; - item.useAnimation = 6; + item.useTime = 3; + item.reuseDelay = 12; + item.useAnimation = 9; item.useStyle = 5; item.noMelee = true; item.knockBack = 5f; @@ -48,7 +48,7 @@ namespace CalamityMod.Items.Weapons.Ranged for (int i = 0; i < 2; i++) { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i == 1 ? 0 : 2)); - Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, 242, damage, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, ProjectileID.BulletHighVelocity, damage, knockBack, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Ranged/MagnomalyCannon.cs b/Items/Weapons/Ranged/MagnomalyCannon.cs index e130db7130..46b8b7340f 100644 --- a/Items/Weapons/Ranged/MagnomalyCannon.cs +++ b/Items/Weapons/Ranged/MagnomalyCannon.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 1600; + item.damage = 1450; item.ranged = true; item.width = 84; item.height = 30; diff --git a/Items/Weapons/Ranged/MineralMortar.cs b/Items/Weapons/Ranged/MineralMortar.cs index 301b2db2d3..be4953ee6a 100644 --- a/Items/Weapons/Ranged/MineralMortar.cs +++ b/Items/Weapons/Ranged/MineralMortar.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Ranged return new Vector2(-10, 0); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Ranged/OpalStriker.cs b/Items/Weapons/Ranged/OpalStriker.cs index a6be6ea391..672f5635f7 100644 --- a/Items/Weapons/Ranged/OpalStriker.cs +++ b/Items/Weapons/Ranged/OpalStriker.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -34,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.useAmmo = 97; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Ranged/P90.cs b/Items/Weapons/Ranged/P90.cs index 71a453390c..ea248f11b0 100644 --- a/Items/Weapons/Ranged/P90.cs +++ b/Items/Weapons/Ranged/P90.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.useStyle = 5; item.noMelee = true; item.knockBack = 1.5f; - item.value = Item.buyPrice(0, 80, 0, 0); - item.rare = 8; + item.value = Item.buyPrice(0, 60, 0, 0); + item.rare = 7; item.UseSound = SoundID.Item11; item.autoReuse = true; item.shoot = 10; diff --git a/Items/Weapons/Ranged/Photoviscerator.cs b/Items/Weapons/Ranged/Photoviscerator.cs index 364b0bf5c4..0442c34c4f 100644 --- a/Items/Weapons/Ranged/Photoviscerator.cs +++ b/Items/Weapons/Ranged/Photoviscerator.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 270; + item.damage = 250; item.ranged = true; item.width = 84; item.height = 30; diff --git a/Items/Weapons/Ranged/ProporsePistol.cs b/Items/Weapons/Ranged/ProporsePistol.cs index 7521cfc973..02947b9352 100644 --- a/Items/Weapons/Ranged/ProporsePistol.cs +++ b/Items/Weapons/Ranged/ProporsePistol.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -33,7 +34,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.useAmmo = 97; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Ranged/RaidersGlory.cs b/Items/Weapons/Ranged/RaidersGlory.cs index 38fb9c5a4c..0e0b3a749a 100644 --- a/Items/Weapons/Ranged/RaidersGlory.cs +++ b/Items/Weapons/Ranged/RaidersGlory.cs @@ -1,3 +1,4 @@ +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -34,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.useAmmo = 40; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { int projectile = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ProjectileID.IchorArrow, damage, knockBack, player.whoAmI, 0f, 0f); Main.projectile[projectile].extraUpdates++; diff --git a/Items/Weapons/Ranged/Scorpion.cs b/Items/Weapons/Ranged/Scorpion.cs index ac327b6e9d..af08c157ad 100644 --- a/Items/Weapons/Ranged/Scorpion.cs +++ b/Items/Weapons/Ranged/Scorpion.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Items.Weapons.Ranged return base.CanUseItem(player); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { if (player.altFunctionUse == 2) { diff --git a/Items/Weapons/Ranged/Seabow.cs b/Items/Weapons/Ranged/Seabow.cs index d1c96c3770..83d15e5146 100644 --- a/Items/Weapons/Ranged/Seabow.cs +++ b/Items/Weapons/Ranged/Seabow.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -34,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.useAmmo = 40; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { float SpeedX = speedX + (float)Main.rand.Next(-30, 31) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-30, 31) * 0.05f; diff --git a/Items/Weapons/Ranged/Shellshooter.cs b/Items/Weapons/Ranged/Shellshooter.cs index 0dd9232071..7858e7c7f2 100644 --- a/Items/Weapons/Ranged/Shellshooter.cs +++ b/Items/Weapons/Ranged/Shellshooter.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -34,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.useAmmo = 40; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0.0f, 0.0f); return false; diff --git a/Items/Weapons/Ranged/SpectralstormCannon.cs b/Items/Weapons/Ranged/SpectralstormCannon.cs index 90727d9e56..60b6c0023b 100644 --- a/Items/Weapons/Ranged/SpectralstormCannon.cs +++ b/Items/Weapons/Ranged/SpectralstormCannon.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Items.Weapons.Ranged return true; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { int num6 = Main.rand.Next(1, 2); for (int index = 0; index < num6; ++index) diff --git a/Items/Weapons/Ranged/TerraFlameburster.cs b/Items/Weapons/Ranged/TerraFlameburster.cs index 5780520b5b..e038769d50 100644 --- a/Items/Weapons/Ranged/TerraFlameburster.cs +++ b/Items/Weapons/Ranged/TerraFlameburster.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 48; + item.damage = 43; item.ranged = true; item.width = 68; item.height = 22; diff --git a/Items/Weapons/Rogue/BrackishFlask.cs b/Items/Weapons/Rogue/BrackishFlask.cs index 1c0ee14aba..0d96808f74 100644 --- a/Items/Weapons/Rogue/BrackishFlask.cs +++ b/Items/Weapons/Rogue/BrackishFlask.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { item.width = 28; - item.damage = 40; + item.damage = 60; item.noMelee = true; item.noUseGraphic = true; item.useAnimation = 35; diff --git a/Items/Weapons/Rogue/CorpusAvertor.cs b/Items/Weapons/Rogue/CorpusAvertor.cs index 2b5627bb41..755992626d 100644 --- a/Items/Weapons/Rogue/CorpusAvertor.cs +++ b/Items/Weapons/Rogue/CorpusAvertor.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Hybrid; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -41,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Rogue flat += lifeAmount * 0.2f * player.Calamity().throwingDamage; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); return false; diff --git a/Items/Weapons/Rogue/CraniumSmasher.cs b/Items/Weapons/Rogue/CraniumSmasher.cs index a44cde894d..9b22d9522f 100644 --- a/Items/Weapons/Rogue/CraniumSmasher.cs +++ b/Items/Weapons/Rogue/CraniumSmasher.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -33,7 +34,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { if (Main.rand.Next(0, 5) == 0) { diff --git a/Items/Weapons/Rogue/DeepWounder.cs b/Items/Weapons/Rogue/DeepWounder.cs index 940802e836..9b33d8e8bb 100644 --- a/Items/Weapons/Rogue/DeepWounder.cs +++ b/Items/Weapons/Rogue/DeepWounder.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { item.width = 52; - item.damage = 125; + item.damage = 106; item.noMelee = true; item.noUseGraphic = true; item.useAnimation = 23; diff --git a/Items/Weapons/Rogue/DefectiveSphere.cs b/Items/Weapons/Rogue/DefectiveSphere.cs index 8c0aa9e116..b8ffaafa67 100644 --- a/Items/Weapons/Rogue/DefectiveSphere.cs +++ b/Items/Weapons/Rogue/DefectiveSphere.cs @@ -3,12 +3,13 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Rogue { public class DefectiveSphere : RogueWeapon { - public static int BaseDamage = 115; + public static int BaseDamage = 130; public static float Speed = 15f; public override void SetStaticDefaults() @@ -39,7 +40,7 @@ Stealth strikes launch all 4 sphere types at once"); item.rare = 8; item.Calamity().rogue = true; - item.shoot = ModContent.ProjectileType(); + item.shoot = ProjectileType(); item.shootSpeed = Speed; } @@ -51,7 +52,7 @@ Stealth strikes launch all 4 sphere types at once"); { return true; } - else if ((player.ownedProjectileCounts[item.shoot] + player.ownedProjectileCounts[ModContent.ProjectileType()] + player.ownedProjectileCounts[ModContent.ProjectileType()] + player.ownedProjectileCounts[ModContent.ProjectileType()]) >= UseMax) + else if ((player.ownedProjectileCounts[item.shoot] + player.ownedProjectileCounts[ProjectileType()] + player.ownedProjectileCounts[ProjectileType()] + player.ownedProjectileCounts[ProjectileType()]) >= UseMax) { return false; } @@ -63,28 +64,30 @@ Stealth strikes launch all 4 sphere types at once"); public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - int sphereType = type; - if (Main.rand.NextBool(4)) - sphereType = ModContent.ProjectileType(); - else if (Main.rand.NextBool(3)) - sphereType = ModContent.ProjectileType(); - else if (Main.rand.NextBool(2)) - sphereType = ModContent.ProjectileType(); - float SpeedX = speedX + (float)Main.rand.Next(-30, 31) * 0.05f; - float SpeedY = speedY + (float)Main.rand.Next(-30, 31) * 0.05f; - float SpeedX2 = speedX + (float)Main.rand.Next(-30, 31) * 0.05f; - float SpeedY2 = speedY + (float)Main.rand.Next(-30, 31) * 0.05f; - float SpeedX3 = speedX + (float)Main.rand.Next(-30, 31) * 0.05f; - float SpeedY3 = speedY + (float)Main.rand.Next(-30, 31) * 0.05f; - float SpeedX4 = speedX + (float)Main.rand.Next(-30, 31) * 0.05f; - float SpeedY4 = speedY + (float)Main.rand.Next(-30, 31) * 0.05f; + int sphereType = Utils.SelectRandom(Main.rand, new int[] + { + type, + ProjectileType(), + ProjectileType(), + ProjectileType() + }); + + //Kinda ugly but idk how to make it cleaner + float SpeedX = speedX + Main.rand.NextFloat(-30, 30) * 0.05f; + float SpeedY = speedY + Main.rand.NextFloat(-30, 30) * 0.05f; + float SpeedX2 = speedX + Main.rand.NextFloat(-30, 30) * 0.05f; + float SpeedY2 = speedY + Main.rand.NextFloat(-30, 30) * 0.05f; + float SpeedX3 = speedX + Main.rand.NextFloat(-30, 30) * 0.05f; + float SpeedY3 = speedY + Main.rand.NextFloat(-30, 30) * 0.05f; + float SpeedX4 = speedX + Main.rand.NextFloat(-30, 30) * 0.05f; + float SpeedY4 = speedY + Main.rand.NextFloat(-30, 30) * 0.05f; if (player.Calamity().StealthStrikeAvailable()) { int stealth = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage / 2, knockBack, player.whoAmI, 0f, 0f); - int stealth2 = Projectile.NewProjectile(position.X, position.Y, SpeedX2, SpeedY2, ModContent.ProjectileType(), damage / 2, knockBack, player.whoAmI, 0f, 0f); - int stealth3 = Projectile.NewProjectile(position.X, position.Y, SpeedX3, SpeedY3, ModContent.ProjectileType(), damage / 2, knockBack, player.whoAmI, 0f, 0f); - int stealth4 = Projectile.NewProjectile(position.X, position.Y, SpeedX4, SpeedY4, ModContent.ProjectileType(), damage / 2, knockBack, player.whoAmI, 0f, 0f); + int stealth2 = Projectile.NewProjectile(position.X, position.Y, SpeedX2, SpeedY2, ProjectileType(), damage / 2, knockBack, player.whoAmI, 0f, 0f); + int stealth3 = Projectile.NewProjectile(position.X, position.Y, SpeedX3, SpeedY3, ProjectileType(), damage / 2, knockBack, player.whoAmI, 0f, 0f); + int stealth4 = Projectile.NewProjectile(position.X, position.Y, SpeedX4, SpeedY4, ProjectileType(), damage / 2, knockBack, player.whoAmI, 0f, 0f); Main.projectile[stealth].Calamity().stealthStrike = true; Main.projectile[stealth2].Calamity().stealthStrike = true; Main.projectile[stealth3].Calamity().stealthStrike = true; diff --git a/Items/Weapons/Rogue/EclipsesFall.cs b/Items/Weapons/Rogue/EclipsesFall.cs index a5b5051e3c..981ad55e52 100644 --- a/Items/Weapons/Rogue/EclipsesFall.cs +++ b/Items/Weapons/Rogue/EclipsesFall.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -37,7 +38,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { if (player.Calamity().StealthStrikeAvailable()) { diff --git a/Items/Weapons/Rogue/FantasyTalisman.cs b/Items/Weapons/Rogue/FantasyTalisman.cs index 4201d9f041..6da32df8f8 100644 --- a/Items/Weapons/Rogue/FantasyTalisman.cs +++ b/Items/Weapons/Rogue/FantasyTalisman.cs @@ -20,7 +20,7 @@ Stealth strikes release more souls and leave behind souls as they travel"); public override void SafeSetDefaults() { item.width = 34; - item.damage = 80; + item.damage = 93; item.noMelee = true; item.consumable = true; item.noUseGraphic = true; @@ -57,7 +57,7 @@ Stealth strikes release more souls and leave behind souls as they travel"); recipe.AddIngredient(ItemID.Silk, 3); recipe.AddIngredient(ItemID.Ectoplasm, 5); recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this, 100); + recipe.SetResult(this, 150); recipe.AddRecipe(); } } diff --git a/Items/Weapons/Rogue/FlameScythe.cs b/Items/Weapons/Rogue/FlameScythe.cs index f717c72d5f..55d7aa87c8 100644 --- a/Items/Weapons/Rogue/FlameScythe.cs +++ b/Items/Weapons/Rogue/FlameScythe.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Rogue { item.width = 50; item.height = 48; - item.damage = 100; + item.damage = 90; item.noMelee = true; item.noUseGraphic = true; item.autoReuse = true; diff --git a/Items/Weapons/Rogue/FrostcrushValari.cs b/Items/Weapons/Rogue/FrostcrushValari.cs index 4f258e2366..40be84c827 100644 --- a/Items/Weapons/Rogue/FrostcrushValari.cs +++ b/Items/Weapons/Rogue/FrostcrushValari.cs @@ -21,7 +21,7 @@ Stealth strikes throws three short ranged boomerangs along with a spread of icic public override void SafeSetDefaults() { - item.damage = 70; + item.damage = 100; item.knockBack = 12; item.thrown = true; item.crit = 16; diff --git a/Items/Weapons/Rogue/Hypothermia.cs b/Items/Weapons/Rogue/Hypothermia.cs index 9755c7b594..1f7e04b2a3 100644 --- a/Items/Weapons/Rogue/Hypothermia.cs +++ b/Items/Weapons/Rogue/Hypothermia.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { counter++; if (counter >= 7) diff --git a/Items/Weapons/Rogue/KelvinCatalyst.cs b/Items/Weapons/Rogue/KelvinCatalyst.cs index 4077194c6d..f8dad5bc9b 100644 --- a/Items/Weapons/Rogue/KelvinCatalyst.cs +++ b/Items/Weapons/Rogue/KelvinCatalyst.cs @@ -5,6 +5,7 @@ using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.Hybrid; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -40,7 +41,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().customRarity = CalamityRarity.Dedicated; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); return false; diff --git a/Items/Weapons/Rogue/LunarKunai.cs b/Items/Weapons/Rogue/LunarKunai.cs index a3b0f827c8..9419c1db49 100644 --- a/Items/Weapons/Rogue/LunarKunai.cs +++ b/Items/Weapons/Rogue/LunarKunai.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { float num72 = item.shootSpeed; Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); diff --git a/Items/Weapons/Rogue/Malachite.cs b/Items/Weapons/Rogue/Malachite.cs index d7a1285cf9..5f8a435485 100644 --- a/Items/Weapons/Rogue/Malachite.cs +++ b/Items/Weapons/Rogue/Malachite.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -59,7 +60,7 @@ namespace CalamityMod.Items.Weapons.Rogue return base.CanUseItem(player); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { if (player.altFunctionUse == 2) { diff --git a/Items/Weapons/Rogue/Mycoroot.cs b/Items/Weapons/Rogue/Mycoroot.cs index 146f84dafd..3a8af59781 100644 --- a/Items/Weapons/Rogue/Mycoroot.cs +++ b/Items/Weapons/Rogue/Mycoroot.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { float SpeedX = speedX + (float)Main.rand.Next(-30, 31) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-30, 31) * 0.05f; diff --git a/Items/Weapons/Rogue/ProfanedTrident.cs b/Items/Weapons/Rogue/ProfanedTrident.cs index e70882ac58..13ca758e8b 100644 --- a/Items/Weapons/Rogue/ProfanedTrident.cs +++ b/Items/Weapons/Rogue/ProfanedTrident.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -35,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().customRarity = CalamityRarity.DarkBlue; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); diff --git a/Items/Weapons/Rogue/Quasar.cs b/Items/Weapons/Rogue/Quasar.cs index cf4e42f337..99ef2e8cd1 100644 --- a/Items/Weapons/Rogue/Quasar.cs +++ b/Items/Weapons/Rogue/Quasar.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -35,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().customRarity = CalamityRarity.RareVariant; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 1f, 0f); return false; diff --git a/Items/Weapons/Rogue/RogueWeapon.cs b/Items/Weapons/Rogue/RogueWeapon.cs index f088ae1b35..ba11775685 100644 --- a/Items/Weapons/Rogue/RogueWeapon.cs +++ b/Items/Weapons/Rogue/RogueWeapon.cs @@ -20,16 +20,19 @@ namespace CalamityMod.Items.Weapons.Rogue item.summon = false; } + // Simply add the player's dedicated rogue damage. + // Rogue weapons are internally throwing so they already benefit from throwing damage boosts. // 5E-06 to prevent downrounding is not needed anymore, added by TML itself public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) { add += player.Calamity().throwingDamage - 1f; } - // Calculates a rogue weapon's crit chance using the player's rogue crit chance. + // Simply add the player's dedicated rogue crit chance. + // Rogue crit isn't boosted by Calamity universal crit boosts, so this won't double-add universal crit. public override void GetWeaponCrit(Player player, ref int crit) { - crit = item.crit + player.Calamity().throwingCrit; + crit += player.Calamity().throwingCrit; } public override float UseTimeMultiplier(Player player) diff --git a/Items/Weapons/Rogue/RoyalKnives.cs b/Items/Weapons/Rogue/RoyalKnives.cs index 491cb3d31e..2814bc4c33 100644 --- a/Items/Weapons/Rogue/RoyalKnives.cs +++ b/Items/Weapons/Rogue/RoyalKnives.cs @@ -1,5 +1,5 @@ using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Hybrid; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using System; @@ -93,7 +93,7 @@ namespace CalamityMod.Items.Weapons.Rogue num149 *= num80; float x4 = vector2.X; float y4 = vector2.Y; - Projectile.NewProjectile(x4, y4, num148, num149, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(x4, y4, num148, num149, type, damage, knockBack, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Rogue/ScourgeoftheCosmosThrown.cs b/Items/Weapons/Rogue/ScourgeoftheCosmosThrown.cs index 07806dd396..9be81be0ae 100644 --- a/Items/Weapons/Rogue/ScourgeoftheCosmosThrown.cs +++ b/Items/Weapons/Rogue/ScourgeoftheCosmosThrown.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Hybrid; using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -36,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().customRarity = CalamityRarity.Violet; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); return false; diff --git a/Items/Weapons/Rogue/ShockGrenade.cs b/Items/Weapons/Rogue/ShockGrenade.cs index 3d44ae0a60..f607055862 100644 --- a/Items/Weapons/Rogue/ShockGrenade.cs +++ b/Items/Weapons/Rogue/ShockGrenade.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { item.width = 14; - item.damage = 100; + item.damage = 90; item.noMelee = true; item.noUseGraphic = true; item.consumable = true; diff --git a/Items/Weapons/Rogue/SpearofDestiny.cs b/Items/Weapons/Rogue/SpearofDestiny.cs index dff97777b8..59978ead10 100644 --- a/Items/Weapons/Rogue/SpearofDestiny.cs +++ b/Items/Weapons/Rogue/SpearofDestiny.cs @@ -37,12 +37,11 @@ namespace CalamityMod.Items.Weapons.Rogue public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - int numProj = 2; - float rotation = MathHelper.ToRadians(3); - for (int i = 0; i < numProj + 1; i++) + int index = 7; + for (int i = -index; i <= index; i += index) { - Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); - Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, i == 1 ? type : ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); + Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, i != 0 ? type : ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Rogue/SylvanSlasher.cs b/Items/Weapons/Rogue/SylvanSlasher.cs index 9a8288fc70..f05db9a4c8 100644 --- a/Items/Weapons/Rogue/SylvanSlasher.cs +++ b/Items/Weapons/Rogue/SylvanSlasher.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue @@ -34,7 +35,7 @@ Does not consume stealth and cannot stealth strike"); item.Calamity().customRarity = CalamityRarity.Turquoise; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/Rogue/TimeBolt.cs b/Items/Weapons/Rogue/TimeBolt.cs index 31d938e9c3..51e85b6ee3 100644 --- a/Items/Weapons/Rogue/TimeBolt.cs +++ b/Items/Weapons/Rogue/TimeBolt.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -25,7 +26,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.useAnimation = 20; item.useStyle = 1; item.useTime = 20; - item.knockBack = 2f; + item.knockBack = 4f; item.UseSound = SoundID.Item1; item.autoReuse = true; item.value = Item.buyPrice(1, 40, 0, 0); @@ -36,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); diff --git a/Items/Weapons/Rogue/TruePaladinsHammer.cs b/Items/Weapons/Rogue/TruePaladinsHammer.cs index d8bfd06b6b..eeaee61fc5 100644 --- a/Items/Weapons/Rogue/TruePaladinsHammer.cs +++ b/Items/Weapons/Rogue/TruePaladinsHammer.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { item.width = 14; - item.damage = 101; + item.damage = 81; item.noMelee = true; item.noUseGraphic = true; item.autoReuse = true; diff --git a/Items/Weapons/Summon/AbandonedSlimeStaff.cs b/Items/Weapons/Summon/AbandonedSlimeStaff.cs index 74f8643fc1..3032e41aec 100644 --- a/Items/Weapons/Summon/AbandonedSlimeStaff.cs +++ b/Items/Weapons/Summon/AbandonedSlimeStaff.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Items.Weapons.Summon return slimeSlots >= 1; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { for (int x = 0; x < Main.projectile.Length; x++) { diff --git a/Items/Weapons/Summon/BensUmbrella.cs b/Items/Weapons/Summon/BensUmbrella.cs index d448b643a0..0132e1a567 100644 --- a/Items/Weapons/Summon/BensUmbrella.cs +++ b/Items/Weapons/Summon/BensUmbrella.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Items.Weapons.Summon public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && player.maxMinions >= 5; - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { position = Main.MouseWorld; speedX = 0; diff --git a/Items/Weapons/Summon/DreadmineStaff.cs b/Items/Weapons/Summon/DreadmineStaff.cs index 7a90d5cd13..2b873ac060 100644 --- a/Items/Weapons/Summon/DreadmineStaff.cs +++ b/Items/Weapons/Summon/DreadmineStaff.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables; using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -35,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Summon item.sentry = true; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { position = Main.MouseWorld; speedX = 0; diff --git a/Items/Weapons/Summon/EnergyStaff.cs b/Items/Weapons/Summon/EnergyStaff.cs index f32e7a1133..a4a858dfa5 100644 --- a/Items/Weapons/Summon/EnergyStaff.cs +++ b/Items/Weapons/Summon/EnergyStaff.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon @@ -31,7 +32,7 @@ namespace CalamityMod.Items.Weapons.Summon item.Calamity().customRarity = CalamityRarity.Turquoise; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { position = Main.MouseWorld; speedX = 0; diff --git a/Items/Weapons/Summon/GodspawnHelixStaff.cs b/Items/Weapons/Summon/GodspawnHelixStaff.cs index f14ce99263..d1fd6b2773 100644 --- a/Items/Weapons/Summon/GodspawnHelixStaff.cs +++ b/Items/Weapons/Summon/GodspawnHelixStaff.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -15,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - item.damage = 50; + item.damage = 60; item.mana = 10; item.width = 50; item.height = 50; @@ -31,7 +32,7 @@ namespace CalamityMod.Items.Weapons.Summon item.summon = true; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { position = Main.MouseWorld; speedX = 0; diff --git a/Items/Weapons/Summon/InfectedRemote.cs b/Items/Weapons/Summon/InfectedRemote.cs index 3520ec36a4..6b379cbbb8 100644 --- a/Items/Weapons/Summon/InfectedRemote.cs +++ b/Items/Weapons/Summon/InfectedRemote.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Items.Weapons.Summon return viruliSlots >= 1 && player.ownedProjectileCounts[item.shoot] <= 0; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { for (int x = 0; x < Main.projectile.Length; x++) { diff --git a/Items/Weapons/Summon/LanternoftheSoul.cs b/Items/Weapons/Summon/LanternoftheSoul.cs index 6932952940..95673a3af0 100644 --- a/Items/Weapons/Summon/LanternoftheSoul.cs +++ b/Items/Weapons/Summon/LanternoftheSoul.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Summon item.UseSound = SoundID.Item44; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { position = Main.MouseWorld; speedX = 0; diff --git a/Items/Weapons/Summon/SandSharknadoStaff.cs b/Items/Weapons/Summon/SandSharknadoStaff.cs index 75abcd913e..8e82126311 100644 --- a/Items/Weapons/Summon/SandSharknadoStaff.cs +++ b/Items/Weapons/Summon/SandSharknadoStaff.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - item.damage = 30; + item.damage = 35; item.mana = 10; item.width = 48; item.height = 56; diff --git a/Items/Weapons/Summon/Sirius.cs b/Items/Weapons/Summon/Sirius.cs index d20160ce12..37e60e7d4b 100644 --- a/Items/Weapons/Summon/Sirius.cs +++ b/Items/Weapons/Summon/Sirius.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Items.Weapons.Summon return siriusSlots >= 1; } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { for (int x = 0; x < Main.projectile.Length; x++) { diff --git a/Items/Weapons/Summon/SpikecragStaff.cs b/Items/Weapons/Summon/SpikecragStaff.cs index 2445b8f8a1..e59accbe2a 100644 --- a/Items/Weapons/Summon/SpikecragStaff.cs +++ b/Items/Weapons/Summon/SpikecragStaff.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - item.damage = 70; + item.damage = 56; item.mana = 10; item.summon = true; item.sentry = true; diff --git a/Items/Weapons/Summon/SunGodStaff.cs b/Items/Weapons/Summon/SunGodStaff.cs index 3d402eeb60..dd305b8186 100644 --- a/Items/Weapons/Summon/SunGodStaff.cs +++ b/Items/Weapons/Summon/SunGodStaff.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -44,12 +45,12 @@ namespace CalamityMod.Items.Weapons.Summon recipe.AddRecipe(); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { position = Main.MouseWorld; speedX = 0; speedY = 0; - for (int x = 0; x < 1000; x++) + for (int x = 0; x < Main.maxProjectiles; x++) { Projectile projectile = Main.projectile[x]; if (projectile.active && projectile.owner == player.whoAmI && projectile.type == ModContent.ProjectileType()) diff --git a/Items/Weapons/Summon/SunSpiritStaff.cs b/Items/Weapons/Summon/SunSpiritStaff.cs index 392e0d7c34..a89447ebeb 100644 --- a/Items/Weapons/Summon/SunSpiritStaff.cs +++ b/Items/Weapons/Summon/SunSpiritStaff.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -41,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Summon recipe.AddRecipe(); } - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { position = Main.MouseWorld; speedX = 0; diff --git a/Items/Weapons/Summon/TundraFlameBlossomsStaff.cs b/Items/Weapons/Summon/TundraFlameBlossomsStaff.cs index c631c0eaa3..bfd4852479 100644 --- a/Items/Weapons/Summon/TundraFlameBlossomsStaff.cs +++ b/Items/Weapons/Summon/TundraFlameBlossomsStaff.cs @@ -11,12 +11,13 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetStaticDefaults() { DisplayName.SetDefault("Tundra Flame Blossoms Staff"); - Tooltip.SetDefault("Summons three unusual flowers over your head"); + Tooltip.SetDefault("Summons three unusual flowers over your head\n" + + "Each flower consumes one minion slot"); } public override void SetDefaults() { - item.damage = 39; + item.damage = 45; item.mana = 10; item.width = 52; item.height = 60; @@ -32,9 +33,19 @@ namespace CalamityMod.Items.Weapons.Summon item.shootSpeed = 10f; item.summon = true; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] < 3; //If you already have all 3, no need to resummon + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile proj = Main.projectile[x]; + if (proj.active && proj.owner == player.whoAmI && proj.type == type) + { + proj.Kill(); + } + } for (int i = 0; i < 3; i++) { Projectile blossom = Projectile.NewProjectileDirect(player.Center, Vector2.Zero, type, damage, knockBack, player.whoAmI, 0f, 0f); diff --git a/Items/Weapons/Typeless/AethersWhisper.cs b/Items/Weapons/Typeless/AethersWhisper.cs index 1404877502..fa581c0416 100644 --- a/Items/Weapons/Typeless/AethersWhisper.cs +++ b/Items/Weapons/Typeless/AethersWhisper.cs @@ -40,15 +40,9 @@ namespace CalamityMod.Items.Weapons.Typeless item.Calamity().customRarity = CalamityRarity.PureGreen; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - public override bool AltFunctionUse(Player player) - { - return true; - } + public override bool AltFunctionUse(Player player) => true; public override bool CanUseItem(Player player) { @@ -78,7 +72,7 @@ namespace CalamityMod.Items.Weapons.Typeless { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 3); recipe.AddTile(TileID.LunarCraftingStation); diff --git a/Items/Weapons/Typeless/RelicOfDeliverance.cs b/Items/Weapons/Typeless/RelicOfDeliverance.cs index 4bffd8e0d6..481b20a897 100644 --- a/Items/Weapons/Typeless/RelicOfDeliverance.cs +++ b/Items/Weapons/Typeless/RelicOfDeliverance.cs @@ -12,6 +12,7 @@ namespace CalamityMod.Items.Weapons.Typeless DisplayName.SetDefault("Relic of Deliverance"); Tooltip.SetDefault("Summons a spear that causes you to lunge towards the mouse position\n" + "The spear requires a charge-up. The longer the charge, the more strong the lunge\n" + + "The spear disappears immediately if you are not holding this item while charging\n" + "If enough time has passed or the spear collides into a wall, the spear dies and the lunge ends"); } diff --git a/Items/Weapons/Typeless/RelicOfResilience.cs b/Items/Weapons/Typeless/RelicOfResilience.cs index 31f8cb212b..29be8f0f03 100644 --- a/Items/Weapons/Typeless/RelicOfResilience.cs +++ b/Items/Weapons/Typeless/RelicOfResilience.cs @@ -11,16 +11,18 @@ namespace CalamityMod.Items.Weapons.Typeless public class RelicOfResilience : ModItem { public const int CooldownSeconds = 5; + public const float WeaknessDR = 0.45f; public override void SetStaticDefaults() { DisplayName.SetDefault("Relic of Resilience"); Tooltip.SetDefault("Summons a bulwark at the mouse position\n" + - "The bulwark takes damage from enemies and all projectiles.\n" + - "On death, the bulwark explodes into a burst of shards\n" + + "The bulwark is killed by enemies and all projectiles.\n" + + "On death, the bulwark explodes into a rotating burst of shards\n" + + "If an enemy is in the area of the shards, its next attack is much weaker. This effect has a cooldown\n" + "After a bit of time, the shards come together to reform the original bulwark.\n" + $"This reformation can only happen {ArtifactOfResilienceBulwark.MaxReformations} times.\n" + "You gain a small cooldown when summoning a new bulwark.\n" + - "If a bulwark or shard already exists, using this item will relocate them"); + "If a bulwark already exists, using this item will relocate it"); } public override void SetDefaults() @@ -39,15 +41,11 @@ namespace CalamityMod.Items.Weapons.Typeless item.shootSpeed = 0f; } public override bool CanUseItem(Player player) => !player.HasBuff(ModContent.BuffType()); - public override bool UseItem(Player player) - { - return true; - } + public override bool UseItem(Player player) => true; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { player.AddBuff(ModContent.BuffType(), CooldownSeconds * 60); - if (player.ownedProjectileCounts[item.shoot] > 0 || - player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + if (player.ownedProjectileCounts[item.shoot] > 0) { for (int i = 0; i < Main.projectile.Length; i++) { @@ -56,33 +54,6 @@ namespace CalamityMod.Items.Weapons.Typeless Main.projectile[i].Center = Main.MouseWorld; Main.projectile[i].netUpdate = true; } - else - { - if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard1) - { - ((ArtifactOfResilienceShard1)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld; - } - if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard2) - { - ((ArtifactOfResilienceShard2)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld; - } - if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard3) - { - ((ArtifactOfResilienceShard3)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld; - } - if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard4) - { - ((ArtifactOfResilienceShard4)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld; - } - if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard5) - { - ((ArtifactOfResilienceShard5)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld; - } - if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard6) - { - ((ArtifactOfResilienceShard6)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld; - } - } } } else diff --git a/Localization/CalamityLocalization.cs b/Localization/CalamityLocalization.cs index 1cdc52e742..83cd81c3f9 100644 --- a/Localization/CalamityLocalization.cs +++ b/Localization/CalamityLocalization.cs @@ -28,7 +28,6 @@ namespace CalamityMod.Localization new [] { "PlantBossText", "The ocean depths are trembling." }, new [] { "BabyBossText", "A plague has befallen the Jungle." }, - new [] { "BabyBossText2", "An ancient automaton roams the land." }, new [] { "MoonBossText", "The profaned flame blazes fiercely!" }, new [] { "MoonBossText2", "Cosmic terrors are watching..." }, diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index df400c6cb5..93e95f268a 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -836,6 +836,7 @@ namespace CalamityMod sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); + sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), new List() { ProjectileType(), ProjectileType(), ProjectileType()}, new List() {1-(1f/3f), 2f/3f, 2f/3f}); diff --git a/NPCs/Abyss/MirageJelly.cs b/NPCs/Abyss/MirageJelly.cs index 1460a8f817..4703c5b19f 100644 --- a/NPCs/Abyss/MirageJelly.cs +++ b/NPCs/Abyss/MirageJelly.cs @@ -162,7 +162,9 @@ namespace CalamityMod.NPCs.Abyss public override bool? CanBeHitByProjectile(Projectile projectile) { if (projectile.minion && !projectile.Calamity().overridesMinionDamagePrevention) - return false; + { + return hasBeenHit; + } return null; } diff --git a/NPCs/Abyss/OarfishHead.cs b/NPCs/Abyss/OarfishHead.cs index a1f6314730..892b749993 100644 --- a/NPCs/Abyss/OarfishHead.cs +++ b/NPCs/Abyss/OarfishHead.cs @@ -27,8 +27,8 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { npc.damage = 30; - npc.width = 16; //36 - npc.height = 16; //20 + npc.width = 59; //36 + npc.height = 38; //20 npc.defense = 10; npc.lifeMax = 2000; npc.aiStyle = -1; diff --git a/NPCs/Abyss/Reaper.cs b/NPCs/Abyss/Reaper.cs index ab184e4e51..3e59dba172 100644 --- a/NPCs/Abyss/Reaper.cs +++ b/NPCs/Abyss/Reaper.cs @@ -675,13 +675,7 @@ namespace CalamityMod.NPCs.Abyss DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedPolterghast, 3, 1, 1); if (CalamityWorld.downedPolterghast) { - float f = Main.rand.NextFloat(); - bool replaceWithRare = f <= 0.01f; // 1/100 chance overall of getting The Reaper - if (f <= 0.3333f) // 1/3 chance of getting Valediction OR The Reaper replacing it - { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !replaceWithRare); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), replaceWithRare); - } + DropHelper.DropItemRIV(npc, ModContent.ItemType(), ModContent.ItemType(), 0.3333f, 0.01f); } } diff --git a/NPCs/AcidRain/AcidEel.cs b/NPCs/AcidRain/AcidEel.cs index 247ed6da77..e62f67678b 100644 --- a/NPCs/AcidRain/AcidEel.cs +++ b/NPCs/AcidRain/AcidEel.cs @@ -32,9 +32,9 @@ namespace CalamityMod.NPCs.AcidRain if (CalamityWorld.downedPolterghast) { - npc.Calamity().DR = 0.3f; - npc.damage = 160; - npc.lifeMax = 6650; + npc.Calamity().RevPlusDR(0.05f); + npc.damage = 120; + npc.lifeMax = 5500; npc.defense = 45; } else if (CalamityWorld.downedAquaticScourge) @@ -89,10 +89,10 @@ namespace CalamityMod.NPCs.AcidRain float maxSpeedY = 4f; if (CalamityWorld.downedPolterghast) { - acceleration = 0.75f; - yAcceleration = 0.25f; - maxSpeedX = 24f; - maxSpeedY = 9f; + acceleration = 0.6f; + yAcceleration = 0.15f; + maxSpeedX = 20f; + maxSpeedY = 7f; } npc.velocity.X += npc.direction * acceleration; diff --git a/NPCs/AcidRain/BloodwormNormal.cs b/NPCs/AcidRain/BloodwormNormal.cs index ce4cdfc89b..430b4314ab 100644 --- a/NPCs/AcidRain/BloodwormNormal.cs +++ b/NPCs/AcidRain/BloodwormNormal.cs @@ -1,4 +1,5 @@ using CalamityMod.Items.SummonItems; +using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -98,6 +99,12 @@ namespace CalamityMod.NPCs.AcidRain Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); } } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return (spawnInfo.player.Calamity().ZoneSulphur && CalamityWorld.downedPolterghast && !CalamityWorld.rainingAcid) ? SpawnCondition.WormCritter.Chance * 1.569f : 0f; + } + public override void OnCatchNPC(Player player, Item item) { try diff --git a/NPCs/AcidRain/CragmawMire.cs b/NPCs/AcidRain/CragmawMire.cs index 9d0382d847..2997931d62 100644 --- a/NPCs/AcidRain/CragmawMire.cs +++ b/NPCs/AcidRain/CragmawMire.cs @@ -212,7 +212,7 @@ namespace CalamityMod.NPCs.AcidRain Gore.NewGore(npc.position, -Vector2.UnitY.RotatedByRandom(0.4f) * 4f, mod.GetGoreSlot("Gores/AcidRain/CragmawMireP1Gore3"), npc.scale); npc.localAI[0] = 1f; } - npc.Calamity().DR = 0.125f; + npc.Calamity().DR = CalamityWorld.revenge ? 0.125f : 0f; npc.HitSound = SoundID.NPCHit1; if (Main.netMode != NetmodeID.MultiplayerClient) { diff --git a/NPCs/AcidRain/FlakCrab.cs b/NPCs/AcidRain/FlakCrab.cs index 48f35362f7..ada6f36eaa 100644 --- a/NPCs/AcidRain/FlakCrab.cs +++ b/NPCs/AcidRain/FlakCrab.cs @@ -32,8 +32,8 @@ namespace CalamityMod.NPCs.AcidRain if (CalamityWorld.downedPolterghast) { - npc.lifeMax = 7500; - npc.Calamity().DR = 0.4f; + npc.lifeMax = 7000; + npc.Calamity().RevPlusDR(0.4f); } npc.knockBackResist = 0f; diff --git a/NPCs/AcidRain/GammaSlime.cs b/NPCs/AcidRain/GammaSlime.cs index 19e172e961..229328a357 100644 --- a/NPCs/AcidRain/GammaSlime.cs +++ b/NPCs/AcidRain/GammaSlime.cs @@ -33,9 +33,9 @@ namespace CalamityMod.NPCs.AcidRain npc.width = 40; npc.height = 44; - npc.damage = 145; - npc.lifeMax = 6410; - npc.Calamity().DR = 0.25f; + npc.damage = 130; + npc.lifeMax = 5915; + npc.Calamity().RevPlusDR(0.15f); npc.defense = 50; npc.aiStyle = aiType = -1; diff --git a/NPCs/AcidRain/NuclearTerror.cs b/NPCs/AcidRain/NuclearTerror.cs index 3c7bb273d1..2b1074f059 100644 --- a/NPCs/AcidRain/NuclearTerror.cs +++ b/NPCs/AcidRain/NuclearTerror.cs @@ -51,7 +51,7 @@ namespace CalamityMod.NPCs.AcidRain { npc.buffImmune[k] = true; } - npc.Calamity().DR = 0.4f; + npc.Calamity().RevPlusDR(0.4f); npc.lavaImmune = false; npc.noGravity = false; npc.noTileCollide = false; diff --git a/NPCs/AcidRain/Orthocera.cs b/NPCs/AcidRain/Orthocera.cs index 0db1bfabe2..6dce668b5a 100644 --- a/NPCs/AcidRain/Orthocera.cs +++ b/NPCs/AcidRain/Orthocera.cs @@ -29,14 +29,14 @@ namespace CalamityMod.NPCs.AcidRain npc.damage = 75; npc.lifeMax = 605; npc.defense = 15; - npc.Calamity().DR = 0.075f; + npc.Calamity().RevPlusDR(0.075f); if (CalamityWorld.downedPolterghast) { - npc.damage = 180; - npc.lifeMax = 5700; + npc.damage = 150; + npc.lifeMax = 4500; npc.defense = 65; - npc.Calamity().DR = 0.35f; + npc.Calamity().RevPlusDR(0.35f); } npc.knockBackResist = 0f; @@ -57,7 +57,7 @@ namespace CalamityMod.NPCs.AcidRain { npc.TargetClosest(false); npc.ai[1] += 1f; - float maxSpeed = CalamityWorld.downedPolterghast ? 18f : 10.5f; + float maxSpeed = CalamityWorld.downedPolterghast ? 12.8f : 10.5f; if (npc.target >= 0 && npc.target < 255) { Player player = Main.player[npc.target]; @@ -106,7 +106,7 @@ namespace CalamityMod.NPCs.AcidRain // And jump/shoot else if (npc.ai[1] % 220f > 180f) { - float yAcceleration = CalamityWorld.downedPolterghast ? 0.11f : 0.05f; + float yAcceleration = CalamityWorld.downedPolterghast ? 0.07f : 0.05f; if (npc.ai[1] % 220f < 200f) { npc.velocity.Y -= yAcceleration; @@ -177,8 +177,8 @@ namespace CalamityMod.NPCs.AcidRain } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { - npc.damage = (int)(npc.damage * 1.2); - npc.lifeMax = (int)(npc.lifeMax * 1.3); + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * 0.85f); } public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/AcidRain/Skyfin.cs b/NPCs/AcidRain/Skyfin.cs index 793d6a2ed9..946524a1b0 100644 --- a/NPCs/AcidRain/Skyfin.cs +++ b/NPCs/AcidRain/Skyfin.cs @@ -36,16 +36,16 @@ namespace CalamityMod.NPCs.AcidRain if (CalamityWorld.downedPolterghast) { - npc.damage = 175; - npc.lifeMax = 6300; + npc.damage = 150; + npc.lifeMax = 5001; npc.defense = 58; - npc.Calamity().DR = 0.2f; + npc.Calamity().RevPlusDR(0.05f); } else if (CalamityWorld.downedAquaticScourge) { npc.damage = 85; npc.lifeMax = 700; - npc.Calamity().DR = 0.1f; + npc.Calamity().RevPlusDR(0.05f); } npc.knockBackResist = 0f; @@ -90,7 +90,7 @@ namespace CalamityMod.NPCs.AcidRain } if ((Math.Abs(player.Center.Y - npc.Center.Y) > 50f && player.wet) || (!player.wet && npc.ai[1] <= 0f)) { - float speedY = CalamityWorld.downedPolterghast ? 15f : 6f; + float speedY = CalamityWorld.downedPolterghast ? 10f : 6f; npc.velocity.Y = (player.Center.Y - npc.Center.Y > 0).ToDirectionInt() * speedY; } if (Math.Abs(npc.velocity.X) < 6f) @@ -130,10 +130,10 @@ namespace CalamityMod.NPCs.AcidRain npc.velocity.X = npc.ai[2]; if (npc.ai[1] > TotalTime - DiveTime * 0.5f) { - float flySpeed = CalamityWorld.downedAquaticScourge ? 0.135f : 0.085f; + float flySpeed = CalamityWorld.downedAquaticScourge ? 0.115f : 0.085f; if (CalamityWorld.downedPolterghast) { - flySpeed = 0.185f; + flySpeed = 0.135f; } npc.velocity.Y -= flySpeed; } @@ -178,11 +178,11 @@ namespace CalamityMod.NPCs.AcidRain float chargeSpeed = 8f; if (CalamityWorld.downedAquaticScourge) { - chargeSpeed = 17f; + chargeSpeed = 14f; } if (CalamityWorld.downedPolterghast) { - chargeSpeed = 24f; + chargeSpeed = 18f; } npc.velocity = npc.DirectionTo(player.Center) * chargeSpeed; } diff --git a/NPCs/AcidRain/SulfurousSkater.cs b/NPCs/AcidRain/SulfurousSkater.cs index 9a175d47ef..28ec6472ca 100644 --- a/NPCs/AcidRain/SulfurousSkater.cs +++ b/NPCs/AcidRain/SulfurousSkater.cs @@ -44,10 +44,10 @@ namespace CalamityMod.NPCs.AcidRain if (CalamityWorld.downedPolterghast) { - npc.damage = 140; - npc.lifeMax = 6600; + npc.damage = 100; + npc.lifeMax = 5000; npc.defense = 33; - npc.Calamity().DR = 0.15f; + npc.Calamity().RevPlusDR(0.15f); } npc.knockBackResist = 0f; @@ -150,7 +150,7 @@ namespace CalamityMod.NPCs.AcidRain else { npc.Calamity().DR = 0f; - float speed = CalamityWorld.downedPolterghast ? 22f : 17f; + float speed = CalamityWorld.downedPolterghast ? 17f : 14f; float inertia = CalamityWorld.downedPolterghast ? 20f : 24.5f; if (npc.Distance(player.Center) < 200f) inertia *= 0.667f; diff --git a/NPCs/AcidRain/Trilobite.cs b/NPCs/AcidRain/Trilobite.cs index 573623b37d..7c863b848b 100644 --- a/NPCs/AcidRain/Trilobite.cs +++ b/NPCs/AcidRain/Trilobite.cs @@ -34,14 +34,14 @@ namespace CalamityMod.NPCs.AcidRain npc.damage = 66; npc.lifeMax = 850; npc.defense = 15; - npc.Calamity().DR = 0.25f; + npc.Calamity().RevPlusDR(0.25f); if (CalamityWorld.downedPolterghast) { - npc.damage = 160; - npc.lifeMax = 7200; + npc.damage = 120; + npc.lifeMax = 4900; npc.defense = 78; - npc.Calamity().DR = 0.4f; + npc.Calamity().RevPlusDR(0.4f); } npc.knockBackResist = 0f; @@ -91,7 +91,7 @@ namespace CalamityMod.NPCs.AcidRain float speed = 15f; if (CalamityWorld.downedPolterghast) { - speed = 28.5f; + speed = 18.5f; } npc.velocity = npc.DirectionTo(player.Center) * speed; @@ -116,8 +116,8 @@ namespace CalamityMod.NPCs.AcidRain float speedY = 9f; if (CalamityWorld.downedPolterghast) { - speedX = 27f; - speedY = 25f; + speedX = 22f; + speedY = 11f; } npc.velocity = npc.DirectionTo(player.Center) * new Vector2(speedX, speedY); npc.netUpdate = true; diff --git a/NPCs/AcidRain/WaterLeech.cs b/NPCs/AcidRain/WaterLeech.cs index 343b5928d2..d9447e9b28 100644 --- a/NPCs/AcidRain/WaterLeech.cs +++ b/NPCs/AcidRain/WaterLeech.cs @@ -31,13 +31,13 @@ namespace CalamityMod.NPCs.AcidRain if (CalamityWorld.downedPolterghast) { - npc.damage = 172; + npc.damage = 120; npc.lifeMax = 4000; npc.defense = 30; } else if (CalamityWorld.downedAquaticScourge) { - npc.damage = 100; + npc.damage = 80; npc.lifeMax = 320; } diff --git a/NPCs/Astral/Twinkler.cs b/NPCs/Astral/Twinkler.cs index d692d17d41..09706f7935 100644 --- a/NPCs/Astral/Twinkler.cs +++ b/NPCs/Astral/Twinkler.cs @@ -32,16 +32,9 @@ namespace CalamityMod.NPCs.Astral //bannerItem = ModContent.ItemType(); } + public override bool? CanBeHitByItem(Player player, Item item) => true; - public override bool? CanBeHitByItem(Player player, Item item) - { - return true; - } - - public override bool? CanBeHitByProjectile(Projectile projectile) - { - return true; - } + public override bool? CanBeHitByProjectile(Projectile projectile) => true; public override void HitEffect(int hitDirection, double damage) { @@ -86,7 +79,31 @@ namespace CalamityMod.NPCs.Astral } } - /// I don't think this works btw. Copying from ExampleCritter.cs failed me ~Ben =( + public override bool Autoload(ref string name) + { + IL.Terraria.Wiring.HitWireSingle += HookStatue; + return base.Autoload(ref name); + } + + /// + /// Change the following code sequence in Wiring.HitWireSingle + /// num8 = (int) Utils.SelectRandom(Main.rand, new short[2] + /// { + /// 355, + /// 358 + /// }); + /// + /// to + /// + /// var arr = new short[2] + /// { + /// 355, + /// 358 + /// }); + /// arr = arr.ToList().Add(id).ToArray(); + /// num8 = Utils.SelectRandom(Main.rand, arr); + /// + /// /// private void HookStatue(ILContext il) { @@ -123,14 +140,9 @@ namespace CalamityMod.NPCs.Astral ; } - // not enough switch instructions - if (targets.Length < 54 - offset) - { - continue; - } - - var target = targets[54 - offset]; - if (target == null) + // get the label for case 54: if it exists + int case54Index = 54 - offset; + if (case54Index < 0 || case54Index >= targets.Length || !(targets[case54Index] is ILLabel target)) { continue; } diff --git a/NPCs/AstrumAureus/AstrumAureus.cs b/NPCs/AstrumAureus/AstrumAureus.cs index c94cb866e8..4299c68e61 100644 --- a/NPCs/AstrumAureus/AstrumAureus.cs +++ b/NPCs/AstrumAureus/AstrumAureus.cs @@ -64,6 +64,7 @@ namespace CalamityMod.NPCs.AstrumAureus npc.buffImmune[BuffID.DryadsWardDebuff] = false; npc.buffImmune[BuffID.Oiled] = false; npc.buffImmune[BuffID.BoneJavelin] = false; + npc.buffImmune[BuffID.Venom] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; diff --git a/NPCs/BrimstoneElemental/Brimling.cs b/NPCs/BrimstoneElemental/Brimling.cs index e1df991d27..494d44fe18 100644 --- a/NPCs/BrimstoneElemental/Brimling.cs +++ b/NPCs/BrimstoneElemental/Brimling.cs @@ -14,7 +14,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental public class Brimling : ModNPC { private bool boostDR = false; - public static float normalDR = 0.2f; + public static float normalDR = 0.15f; public static float boostedDR = 0.8f; public override void SetStaticDefaults() @@ -31,7 +31,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental npc.width = 60; npc.height = 60; npc.defense = 0; - npc.Calamity().DR = normalDR; + npc.Calamity().RevPlusDR(normalDR); npc.lifeMax = 4000; npc.knockBackResist = 0f; for (int k = 0; k < npc.buffImmune.Length; k++) @@ -108,11 +108,10 @@ namespace CalamityMod.NPCs.BrimstoneElemental } // Set DR based on boost status - npc.Calamity().DR = boostDR ? boostedDR : normalDR; + npc.Calamity().DR = boostDR ? boostedDR : CalamityWorld.revenge ? normalDR : 0f; float num1446 = goIntoShell ? 1f : (CalamityWorld.bossRushActive ? 12f : 6f); int num1447 = 480; - float num244; if (npc.localAI[1] == 1f) { npc.localAI[1] = 0f; @@ -163,35 +162,31 @@ namespace CalamityMod.NPCs.BrimstoneElemental if (npc.ai[2] != 0f && npc.ai[3] != 0f) { Main.PlaySound(SoundID.Item8, npc.Center); - int num; - for (int num1449 = 0; num1449 < 20; num1449 = num + 1) + for (int num1449 = 0; num1449 < 20; num1449++) { int num1450 = Dust.NewDust(npc.position, npc.width, npc.height, 235, 0f, 0f, 100, Color.Transparent, 1f); Dust dust = Main.dust[num1450]; dust.velocity *= 3f; Main.dust[num1450].noGravity = true; Main.dust[num1450].scale = 2.5f; - num = num1449; } npc.Center = new Vector2(npc.ai[2] * 16f, npc.ai[3] * 16f); npc.velocity = Vector2.Zero; npc.ai[2] = 0f; npc.ai[3] = 0f; + if (npc.localAI[0] > 240f) //Lower firing cooldown to prevent firing so quickly after a teleport + npc.localAI[0] = 240f; Main.PlaySound(SoundID.Item8, npc.Center); - for (int num1451 = 0; num1451 < 20; num1451 = num + 1) + for (int num1451 = 0; num1451 < 20; num1451++) { int num1452 = Dust.NewDust(npc.position, npc.width, npc.height, 235, 0f, 0f, 100, Color.Transparent, 1f); Dust dust = Main.dust[num1452]; dust.velocity *= 3f; Main.dust[num1452].noGravity = true; Main.dust[num1452].scale = 2.5f; - num = num1451; } } - float[] var_9_48E3C_cp_0 = npc.ai; - int var_9_48E3C_cp_1 = 0; - num244 = var_9_48E3C_cp_0[var_9_48E3C_cp_1]; - var_9_48E3C_cp_0[var_9_48E3C_cp_1] = num244 + 1f; + npc.ai[0] += 1f; if (npc.ai[0] >= (float)num1447 && Main.netMode != NetmodeID.MultiplayerClient) { if (npc.localAI[0] > 260f) diff --git a/NPCs/BrimstoneElemental/BrimstoneElemental.cs b/NPCs/BrimstoneElemental/BrimstoneElemental.cs index 5b25421f28..98e46862e9 100644 --- a/NPCs/BrimstoneElemental/BrimstoneElemental.cs +++ b/NPCs/BrimstoneElemental/BrimstoneElemental.cs @@ -42,6 +42,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental npc.defense = 15; npc.value = Item.buyPrice(0, 12, 0, 0); npc.LifeMaxNERB(30000, 41000, 6500000); + npc.Calamity().RevPlusDR(0.15f); if (CalamityWorld.downedProvidence && !CalamityWorld.bossRushActive) { npc.damage *= 3; diff --git a/NPCs/Bumblebirb/Bumblefuck2.cs b/NPCs/Bumblebirb/Bumblefuck2.cs index 7b6a4556f1..0ac40a6f9f 100644 --- a/NPCs/Bumblebirb/Bumblefuck2.cs +++ b/NPCs/Bumblebirb/Bumblefuck2.cs @@ -275,7 +275,7 @@ namespace CalamityMod.NPCs.Bumblebirb } else if (npc.ai[0] == 2.1f) { - npc.damage = (int)((double)npc.defDamage * 1.5); + npc.damage = (int)(npc.defDamage * 1.5); if (npc.velocity.X < 0f) { npc.direction = -1; diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index eddfabfc54..fb95ce1654 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -1,4 +1,3 @@ -using CalamityMod; using CalamityMod.CalPlayer; using CalamityMod.Dusts; using CalamityMod.Events; @@ -25,7 +24,6 @@ using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -using Terraria.ModLoader.Config; namespace CalamityMod.NPCs { @@ -39,8 +37,8 @@ namespace CalamityMod.NPCs bool death = CalamityWorld.death || CalamityWorld.bossRushActive; // Adjust hostility and stats - if (npc.justHit || (double)npc.life <= (double)npc.lifeMax * 0.99 || CalamityWorld.bossRushActive || - (double)Main.npc[(int)npc.ai[1]].life <= (double)Main.npc[(int)npc.ai[1]].lifeMax * 0.99) + if (npc.justHit || npc.life <= npc.lifeMax * 0.99 || CalamityWorld.bossRushActive || + Main.npc[(int)npc.ai[1]].life <= Main.npc[(int)npc.ai[1]].lifeMax * 0.99) { calamityGlobalNPC.newAI[0] = 1f; npc.damage = npc.defDamage; @@ -74,8 +72,8 @@ namespace CalamityMod.NPCs doSpiral = calamityGlobalNPC.newAI[1] == 0f && calamityGlobalNPC.newAI[3] >= ai3; if (doSpiral) { - int npcPosX = (int)(npc.position.X + (float)(npc.width / 2)) / 16; - int npcPosY = (int)(npc.position.Y + (float)(npc.height / 2)) / 16; + int npcPosX = (int)(npc.position.X + (npc.width / 2)) / 16; + int npcPosY = (int)(npc.position.Y + (npc.height / 2)) / 16; // Barf out enemies int variable = 10; @@ -83,7 +81,7 @@ namespace CalamityMod.NPCs { Main.PlaySound(4, (int)npc.position.X, (int)npc.position.Y, 13); - Vector2 spawnPosition = new Vector2((float)(npcPosX * 16), (float)(npcPosY * 16)); + Vector2 spawnPosition = new Vector2(npcPosX * 16, npcPosY * 16); if (Main.tile[npcPosX, npcPosY] != null) { @@ -108,8 +106,8 @@ namespace CalamityMod.NPCs // Spin velocity float velocity = (float)(Math.PI * 2D) / 120f; - npc.velocity = npc.velocity.RotatedBy((double)(-(double)velocity * npc.localAI[1])); - npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; + npc.velocity = npc.velocity.RotatedBy(-(double)velocity * npc.localAI[1]); + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; // Reset and charge at target if (calamityGlobalNPC.newAI[3] >= ai3 + 180f) @@ -147,9 +145,9 @@ namespace CalamityMod.NPCs lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); Main.npc[lol].realLife = npc.whoAmI; - Main.npc[lol].ai[2] = (float)npc.whoAmI; - Main.npc[lol].ai[1] = (float)Previous; - Main.npc[Previous].ai[0] = (float)lol; + Main.npc[lol].ai[2] = npc.whoAmI; + Main.npc[lol].ai[1] = Previous; + Main.npc[Previous].ai[0] = lol; NetMessage.SendData(23, -1, -1, null, lol, 0f, 0f, 0f, 0); Previous = lol; } @@ -165,8 +163,8 @@ namespace CalamityMod.NPCs if (npc.localAI[0] >= (CalamityWorld.bossRushActive ? 300f : (revenge ? 360f : 420f))) { - int npcPosX = (int)(npc.position.X + (float)(npc.width / 2)) / 16; - int npcPosY = (int)(npc.position.Y + (float)(npc.height / 2)) / 16; + int npcPosX = (int)(npc.position.X + (npc.width / 2)) / 16; + int npcPosY = (int)(npc.position.Y + (npc.height / 2)) / 16; if (npcPosX < 0) npcPosX = 0; @@ -185,7 +183,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 valueBoom = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + Vector2 valueBoom = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float spreadBoom = 15f * 0.0174f; double startAngleBoom = Math.Atan2(npc.velocity.X, npc.velocity.Y) - spreadBoom / 2; double deltaAngleBoom = spreadBoom / 8f; @@ -215,12 +213,12 @@ namespace CalamityMod.NPCs int num3; for (int num321 = 0; num321 < num320; num321 = num3 + 1) { - Vector2 vector15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + Vector2 vector15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); vector15.Normalize(); - vector15 *= (float)Main.rand.Next(50, 401) * (CalamityWorld.bossRushActive ? 0.02f : 0.01f); + vector15 *= Main.rand.Next(50, 401) * (CalamityWorld.bossRushActive ? 0.02f : 0.01f); if (death) vector15 *= 1.1f; - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector15.X, vector15.Y, ModContent.ProjectileType(), damageBoom, 0f, Main.myPlayer, 0f, (float)Main.rand.Next(-45, 1)); + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector15.X, vector15.Y, ModContent.ProjectileType(), damageBoom, 0f, Main.myPlayer, 0f, Main.rand.Next(-45, 1)); num3 = num321; } } @@ -237,18 +235,18 @@ namespace CalamityMod.NPCs if (npc.type == ModContent.NPCType()) { int num = (Main.expertMode || CalamityWorld.bossRushActive) ? 4 : 3; - npc.localAI[0] += (float)Main.rand.Next(num); - if (npc.localAI[0] >= (float)Main.rand.Next(700, 10000)) + npc.localAI[0] += Main.rand.Next(num); + if (npc.localAI[0] >= Main.rand.Next(700, 10000)) { npc.localAI[0] = 0f; npc.TargetClosest(true); if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) { Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 17); - Vector2 vector104 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)(npc.height / 2)); - float num942 = player.position.X + (float)player.width * 0.5f - vector104.X; - float num943 = player.position.Y + (float)player.height * 0.5f - vector104.Y; - float num944 = (float)Math.Sqrt((double)(num942 * num942 + num943 * num943)); + Vector2 vector104 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + (npc.height / 2)); + float num942 = player.position.X + player.width * 0.5f - vector104.X; + float num943 = player.position.Y + player.height * 0.5f - vector104.Y; + float num944 = (float)Math.Sqrt(num942 * num942 + num943 * num943); int projectileType = ModContent.ProjectileType(); int damage = Main.expertMode ? 25 : 30; float num941 = CalamityWorld.bossRushActive ? 7.5f : 5f; @@ -264,17 +262,17 @@ namespace CalamityMod.NPCs } else if (npc.type == ModContent.NPCType()) { - npc.localAI[0] += (float)Main.rand.Next(4); - if (npc.localAI[0] >= (float)Main.rand.Next(700, 10000)) + npc.localAI[0] += Main.rand.Next(4); + if (npc.localAI[0] >= Main.rand.Next(700, 10000)) { npc.localAI[0] = 0f; npc.TargetClosest(true); if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) { - Vector2 vector104 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)(npc.height / 2)); - float num942 = player.position.X + (float)player.width * 0.5f - vector104.X; - float num943 = player.position.Y + (float)player.height * 0.5f - vector104.Y; - float num944 = (float)Math.Sqrt((double)(num942 * num942 + num943 * num943)); + Vector2 vector104 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + (npc.height / 2)); + float num942 = player.position.X + player.width * 0.5f - vector104.X; + float num943 = player.position.Y + player.height * 0.5f - vector104.Y; + float num944 = (float)Math.Sqrt(num942 * num942 + num943 * num943); int projectileType = ModContent.ProjectileType(); int damage = Main.expertMode ? 23 : 28; float num941 = CalamityWorld.bossRushActive ? 12f : 8f; @@ -319,8 +317,8 @@ namespace CalamityMod.NPCs // Despawn bool notOcean = player.position.Y < 800f || - (double)player.position.Y > Main.worldSurface * 16.0 || - (player.position.X > 6400f && player.position.X < (float)(Main.maxTilesX * 16 - 6400)); + player.position.Y > Main.worldSurface * 16.0 || + (player.position.X > 6400f && player.position.X < (Main.maxTilesX * 16 - 6400)); if (player.dead || (notOcean && !CalamityWorld.bossRushActive && !player.Calamity().ZoneSulphur)) { @@ -328,10 +326,10 @@ namespace CalamityMod.NPCs npc.TargetClosest(false); npc.velocity.Y += 2f; - if ((double)npc.position.Y > Main.worldSurface * 16.0) + if (npc.position.Y > Main.worldSurface * 16.0) npc.velocity.Y += 2f; - if ((double)npc.position.Y > Main.worldSurface * 16.0) + if (npc.position.Y > Main.worldSurface * 16.0) { for (int a = 0; a < Main.npc.Length; a++) { @@ -364,9 +362,9 @@ namespace CalamityMod.NPCs // Velocity and movement float num188 = 5f; float num189 = 0.08f; - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = player.position.X + (float)(player.width / 2); - float num192 = player.position.Y + (float)(player.height / 2); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = player.position.X + (player.width / 2); + float num192 = player.position.Y + (player.height / 2); int num42 = -1; int num43 = (int)(player.Center.X / 16f); int num44 = (int)(player.Center.Y / 16f); @@ -390,7 +388,7 @@ namespace CalamityMod.NPCs if (num42 > 0) { num42 *= 16; - float num47 = (float)(num42 + (notOcean ? 800 : 400)); //800 + float num47 = num42 + (notOcean ? 800 : 400); //800 if (calamityGlobalNPC.newAI[0] != 1f) { num192 = num47; @@ -446,68 +444,33 @@ namespace CalamityMod.NPCs npc.velocity *= num49; } } - - if (calamityGlobalNPC.newAI[0] != 1f) - { - for (int num51 = 0; num51 < Main.maxNPCs; num51++) - { - if (Main.npc[num51].active && Main.npc[num51].type == npc.type && num51 != npc.whoAmI) - { - Vector2 vector3 = Main.npc[num51].Center - npc.Center; - if (vector3.Length() < 400f) - { - vector3.Normalize(); - vector3 *= 1000f; - num191 -= vector3.X; - num192 -= vector3.Y; - } - } - } - } - else - { - for (int num52 = 0; num52 < Main.maxNPCs; num52++) - { - if (Main.npc[num52].active && Main.npc[num52].type == npc.type && num52 != npc.whoAmI) - { - Vector2 vector4 = Main.npc[num52].Center - npc.Center; - if (vector4.Length() < 60f) - { - vector4.Normalize(); - vector4 *= 200f; - num191 -= vector4.X; - num192 -= vector4.Y; - } - } - } - } } - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; num191 -= vector18.X; num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); if (!head) { - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; + num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; } catch { } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + npc.rotation = (float)Math.Atan2(num192, num191) + MathHelper.PiOver2; + num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; + num193 = (num193 - num194) / num193; num191 *= num193; num192 *= num193; npc.velocity = Vector2.Zero; @@ -525,8 +488,8 @@ namespace CalamityMod.NPCs } else if (!doSpiral) { - float num196 = System.Math.Abs(num191); - float num197 = System.Math.Abs(num192); + float num196 = Math.Abs(num191); + float num197 = Math.Abs(num192); float num198 = num188 / num193; num191 *= num198; num192 *= num198; @@ -551,14 +514,14 @@ namespace CalamityMod.NPCs if (npc.velocity.Y > num192) npc.velocity.Y -= num189; } - if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) + if (Math.Abs(num192) < num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) { if (npc.velocity.Y > 0f) npc.velocity.Y += num189 * 2f; else npc.velocity.Y -= num189 * 2f; } - if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) + if (Math.Abs(num191) < num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) { if (npc.velocity.X > 0f) npc.velocity.X += num189 * 2f; @@ -575,7 +538,7 @@ namespace CalamityMod.NPCs else if (npc.velocity.X > num191) npc.velocity.X -= num189 * 1.1f; - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) { if (npc.velocity.Y > 0f) npc.velocity.Y += num189; @@ -590,7 +553,7 @@ namespace CalamityMod.NPCs else if (npc.velocity.Y > num192) npc.velocity.Y -= num189 * 1.1f; - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) { if (npc.velocity.X > 0f) npc.velocity.X += num189; @@ -599,7 +562,7 @@ namespace CalamityMod.NPCs } } } - npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; } } #endregion @@ -613,7 +576,7 @@ namespace CalamityMod.NPCs CalamityGlobalNPC.brimstoneElemental = npc.whoAmI; // Emit light - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 1.2f, 0f, 0f); + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 1.2f, 0f, 0f); // Center Vector2 vectorCenter = npc.Center; @@ -662,7 +625,7 @@ namespace CalamityMod.NPCs npc.defense = npc.defDefense; // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; // Variables for buffing the AI bool provy = CalamityWorld.downedProvidence && !CalamityWorld.bossRushActive; @@ -681,7 +644,7 @@ namespace CalamityMod.NPCs { if (Main.rand.Next(3) < dustAmt) { - int dust = Dust.NewDust(vectorCenter - new Vector2((float)size), size * 2, size * 2, 235, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 1.5f); + int dust = Dust.NewDust(vectorCenter - new Vector2(size), size * 2, size * 2, 235, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 1.5f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 0.2f; Main.dust[dust].fadeIn = 1f; @@ -705,7 +668,7 @@ namespace CalamityMod.NPCs // Variables for target location relative to npc location float xDistance = player.Center.X - vectorCenter.X; float yDistance = player.Center.Y - vectorCenter.Y; - float totalDistance = (float)Math.Sqrt((double)(xDistance * xDistance + yDistance * yDistance)); + float totalDistance = (float)Math.Sqrt(xDistance * xDistance + yDistance * yDistance); // Static movement towards target if (npc.ai[0] <= 2f || npc.ai[0] == 5f) @@ -764,8 +727,8 @@ namespace CalamityMod.NPCs return; } npc.ai[0] = 1f; - npc.ai[1] = (float)playerPosX; - npc.ai[2] = (float)playerPosY; + npc.ai[1] = playerPosX; + npc.ai[2] = playerPosY; npc.netUpdate = true; } } @@ -775,7 +738,7 @@ namespace CalamityMod.NPCs else if (npc.ai[0] == 1f) { npc.chaseable = true; - Vector2 position = new Vector2(npc.ai[1] * 16f - (float)(npc.width / 2), npc.ai[2] * 16f - (float)(npc.height / 2)); + Vector2 position = new Vector2(npc.ai[1] * 16f - (npc.width / 2), npc.ai[2] * 16f - (npc.height / 2)); for (int m = 0; m < 5; m++) { int dust = Dust.NewDust(position, npc.width, npc.height, 235, 0f, -1f, 90, default, 2f); @@ -855,9 +818,9 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { float num742 = CalamityWorld.bossRushActive ? 6f : 4f; - float num743 = player.position.X + (float)player.width * 0.5f - vectorCenter.X; - float num744 = player.position.Y + (float)player.height * 0.5f - vectorCenter.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num743 = player.position.X + player.width * 0.5f - vectorCenter.X; + float num744 = player.position.Y + player.height * 0.5f - vectorCenter.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; @@ -871,7 +834,7 @@ namespace CalamityMod.NPCs float rotation = MathHelper.ToRadians(spread); float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); double startAngle = Math.Atan2(num743, num744) - rotation / 2; - double deltaAngle = rotation / (float)numProj; + double deltaAngle = rotation / numProj; double offsetAngle; for (int i = 0; i < numProj; i++) @@ -891,9 +854,9 @@ namespace CalamityMod.NPCs projectileSpeed += projectileSpeedBoost; vectorCenter = npc.Center; - float relativeSpeedX = player.position.X + (float)player.width * 0.5f - vectorCenter.X; - float relativeSpeedY = player.position.Y + (float)player.height * 0.5f - vectorCenter.Y; - float totalRelativeSpeed = (float)Math.Sqrt((double)(relativeSpeedX * relativeSpeedX + relativeSpeedY * relativeSpeedY)); + float relativeSpeedX = player.position.X + player.width * 0.5f - vectorCenter.X; + float relativeSpeedY = player.position.Y + player.height * 0.5f - vectorCenter.Y; + float totalRelativeSpeed = (float)Math.Sqrt(relativeSpeedX * relativeSpeedX + relativeSpeedY * relativeSpeedY); totalRelativeSpeed = projectileSpeed / totalRelativeSpeed; relativeSpeedX *= totalRelativeSpeed; relativeSpeedY *= totalRelativeSpeed; @@ -926,7 +889,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < -3f) npc.velocity.Y = -3f; } - if (npc.position.X + (float)(npc.width / 2) > player.position.X + (float)(player.width / 2) + 150f) //100 + if (npc.position.X + (npc.width / 2) > player.position.X + (player.width / 2) + 150f) //100 { if (npc.velocity.X > 0f) npc.velocity.X *= 0.985f; @@ -936,7 +899,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 8f) npc.velocity.X = 8f; } - if (npc.position.X + (float)(npc.width / 2) < player.position.X + (float)(player.width / 2) - 150f) //100 + if (npc.position.X + (npc.width / 2) < player.position.X + (player.width / 2) - 150f) //100 { if (npc.velocity.X < 0f) npc.velocity.X *= 0.985f; @@ -980,49 +943,45 @@ namespace CalamityMod.NPCs if (CalamityWorld.bossRushActive) projectileSpeed = 12f; - float num180 = player.position.X + (float)player.width * 0.5f - vectorCenter.X; - float num181 = Math.Abs(num180) * 0.1f; - float num182 = player.position.Y + (float)player.height * 0.5f - vectorCenter.Y - num181; - float num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); - npc.netUpdate = true; - num183 = projectileSpeed / num183; - num180 *= num183; - num182 *= num183; + int damage = expertMode ? 25 : 30; - int num184 = expertMode ? 25 : 30; - int num185 = ModContent.ProjectileType(); - vectorCenter.X += num180; - vectorCenter.Y += num182; + vectorCenter = player.Center - vectorCenter; - for (int num186 = 0; num186 < 6; num186++) + float radialOffset = 0.2f; + float diameter = 80f; + + vectorCenter.Y -= Math.Abs(vectorCenter.X) * radialOffset; + vectorCenter = Vector2.Normalize(vectorCenter) * projectileSpeed; + + Vector2 velocity = vectorCenter; + velocity.Normalize(); + velocity *= diameter; + + int totalProjectiles = 6; + float offsetAngle = (float)Math.PI * radialOffset; + + for (int j = 0; j < totalProjectiles; j++) { - num180 = player.position.X + (float)player.width * 0.5f - vectorCenter.X; - num182 = player.position.Y + (float)player.height * 0.5f - vectorCenter.Y; - num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); - num183 = projectileSpeed / num183; - num180 += (float)Main.rand.Next(-80, 81); - num182 += (float)Main.rand.Next(-80, 81); - num180 *= num183; - num182 *= num183; - int projectile = Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, num180, num182, num185, num184 + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); - Main.projectile[projectile].timeLeft = 300; - Main.projectile[projectile].tileCollide = false; + float radians = j - (totalProjectiles - 1f) / 2f; + Vector2 offset = velocity.RotatedBy(offsetAngle * radians, default); + int proj = Projectile.NewProjectile(npc.Center + offset, vectorCenter, ModContent.ProjectileType(), damage + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); + Main.projectile[proj].timeLeft = 300; + Main.projectile[proj].tileCollide = false; } vectorCenter = npc.Center; - int totalProjectiles = 12; + totalProjectiles = 12; float spread = MathHelper.ToRadians(30); // 30 degrees in radians = 0.523599 double startAngle = Math.Atan2(npc.velocity.X, npc.velocity.Y) - spread / 2; // Where the projectiles start spawning at, don't change this - double deltaAngle = spread / (float)totalProjectiles; // Angle between each projectile, 0.04363325 - double offsetAngle; - float velocity = CalamityWorld.bossRushActive ? 9f : 6f; + double deltaAngle = spread / totalProjectiles; // Angle between each projectile, 0.04363325 + double offsetAngle2; int i; for (i = 0; i < 6; i++) { - offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; // Used to be 32 - Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, (float)(Math.Sin(offsetAngle) * velocity), (float)(Math.Cos(offsetAngle) * velocity), ModContent.ProjectileType(), num184 + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); - Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, (float)(-Math.Sin(offsetAngle) * velocity), (float)(-Math.Cos(offsetAngle) * velocity), ModContent.ProjectileType(), num184 + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); + offsetAngle2 = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; // Used to be 32 + Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, (float)(Math.Sin(offsetAngle2) * projectileSpeed), (float)(Math.Cos(offsetAngle2) * projectileSpeed), ModContent.ProjectileType(), damage + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); + Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, (float)(-Math.Sin(offsetAngle2) * projectileSpeed), (float)(-Math.Cos(offsetAngle2) * projectileSpeed), ModContent.ProjectileType(), damage + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); } } } @@ -1109,7 +1068,7 @@ namespace CalamityMod.NPCs Main.PlaySound(29, (int)npc.position.X, (int)npc.position.Y, 104); Vector2 laserVelocity2 = new Vector2(npc.localAI[0], npc.localAI[1]); laserVelocity2.Normalize(); - Projectile.NewProjectile(source, laserVelocity2, ModContent.ProjectileType(), 40 + (provy ? 30 : 0), 0f, Main.myPlayer, 0f, (float)npc.whoAmI); + Projectile.NewProjectile(source, laserVelocity2, ModContent.ProjectileType(), 40 + (provy ? 30 : 0), 0f, Main.myPlayer, 0f, npc.whoAmI); } } } @@ -1140,7 +1099,7 @@ namespace CalamityMod.NPCs { if (npc.ai[1] < 150f && calamityGlobalNPC.newAI[0] == 0f) { - Projectile.NewProjectile(source, laserVelocity, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, (float)npc.whoAmI); + Projectile.NewProjectile(source, laserVelocity, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI); calamityGlobalNPC.newAI[0] = 1f; } else @@ -1149,7 +1108,7 @@ namespace CalamityMod.NPCs { npc.localAI[0] = laserVelocity.X; npc.localAI[1] = laserVelocity.Y; - Projectile.NewProjectile(source.X, source.Y, npc.localAI[0], npc.localAI[1], ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, (float)npc.whoAmI); + Projectile.NewProjectile(source.X, source.Y, npc.localAI[0], npc.localAI[1], ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.whoAmI); } } } @@ -1164,10 +1123,10 @@ namespace CalamityMod.NPCs CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); // Emit light - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 1f, 0f, 0f); + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 1f, 0f, 0f); // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; // Spawn phase 2 Cal if (lifeRatio <= 0.75f && Main.netMode != NetmodeID.MultiplayerClient && !phase2) @@ -1229,16 +1188,16 @@ namespace CalamityMod.NPCs // Spawn brothers if (calamityGlobalNPC.newAI[0] == 0f && npc.life > 0) - calamityGlobalNPC.newAI[0] = (float)npc.lifeMax; + calamityGlobalNPC.newAI[0] = npc.lifeMax; if (npc.life > 0) { if (Main.netMode != NetmodeID.MultiplayerClient) { - int num660 = (int)((double)npc.lifeMax * 0.3); //70%, 40%, and 10% - if ((float)(npc.life + num660) < calamityGlobalNPC.newAI[0]) + int num660 = (int)(npc.lifeMax * 0.3); //70%, 40%, and 10% + if ((npc.life + num660) < calamityGlobalNPC.newAI[0]) { - calamityGlobalNPC.newAI[0] = (float)npc.life; + calamityGlobalNPC.newAI[0] = npc.life; if (calamityGlobalNPC.newAI[0] <= (float)npc.lifeMax * 0.1) { NPC.NewNPC((int)npc.Center.X, (int)npc.position.Y + npc.height, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); @@ -1296,25 +1255,25 @@ namespace CalamityMod.NPCs Player player = Main.player[npc.target]; // Rotation - float num801 = npc.position.X + (float)(npc.width / 2) - player.position.X - (float)(player.width / 2); - float num802 = npc.position.Y + (float)npc.height - 59f - player.position.Y - (float)(player.height / 2); - float num803 = (float)Math.Atan2((double)num802, (double)num801) + 1.57f; + float num801 = npc.position.X + (npc.width / 2) - player.position.X - (player.width / 2); + float num802 = npc.position.Y + npc.height - 59f - player.position.Y - (player.height / 2); + float num803 = (float)Math.Atan2(num802, num801) + MathHelper.PiOver2; if (num803 < 0f) - num803 += 6.283f; - else if ((double)num803 > 6.283) - num803 -= 6.283f; + num803 += MathHelper.TwoPi; + else if (num803 > MathHelper.TwoPi) + num803 -= MathHelper.TwoPi; float num804 = 0.1f; if (npc.rotation < num803) { - if ((double)(num803 - npc.rotation) > 3.1415) + if ((num803 - npc.rotation) > MathHelper.Pi) npc.rotation -= num804; else npc.rotation += num804; } else if (npc.rotation > num803) { - if ((double)(npc.rotation - num803) > 3.1415) + if ((npc.rotation - num803) > MathHelper.Pi) npc.rotation += num804; else npc.rotation -= num804; @@ -1323,9 +1282,9 @@ namespace CalamityMod.NPCs if (npc.rotation > num803 - num804 && npc.rotation < num803 + num804) npc.rotation = num803; if (npc.rotation < 0f) - npc.rotation += 6.283f; - else if ((double)npc.rotation > 6.283) - npc.rotation -= 6.283f; + npc.rotation += MathHelper.TwoPi; + else if (npc.rotation > MathHelper.TwoPi) + npc.rotation -= MathHelper.TwoPi; if (npc.rotation > num803 - num804 && npc.rotation < num803 + num804) npc.rotation = num803; @@ -1383,10 +1342,10 @@ namespace CalamityMod.NPCs num824 *= 1.5f; } - Vector2 vector82 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num825 = player.position.X + (float)(player.width / 2) - vector82.X; - float num826 = player.position.Y + (float)(player.height / 2) - ((CalamityWorld.bossRushActive ? 400f : 300f) + (phase2 ? 60f : 0f)) - vector82.Y; - float num827 = (float)Math.Sqrt((double)(num825 * num825 + num826 * num826)); + Vector2 vector82 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num825 = player.position.X + (player.width / 2) - vector82.X; + float num826 = player.position.Y + (player.height / 2) - ((CalamityWorld.bossRushActive ? 400f : 300f) + (phase2 ? 60f : 0f)) - vector82.Y; + float num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); num827 = num823 / num827; num825 *= num827; num826 *= num827; @@ -1425,8 +1384,8 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - num825 = player.position.X + (float)(player.width / 2) - vector82.X; - num826 = player.position.Y + (float)(player.height / 2) - vector82.Y; + num825 = player.position.X + (player.width / 2) - vector82.X; + num826 = player.position.Y + (player.height / 2) - vector82.Y; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -1450,7 +1409,7 @@ namespace CalamityMod.NPCs int num829 = expertMode ? 34 : 42; int num830 = ModContent.ProjectileType(); - num827 = (float)Math.Sqrt((double)(num825 * num825 + num826 * num826)); + num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); num827 = num828 / num827; num825 *= num827; num826 *= num827; @@ -1476,7 +1435,7 @@ namespace CalamityMod.NPCs float num828 = CalamityWorld.bossRushActive ? 16f : (expertMode ? 13f : 10.5f); int num829 = expertMode ? 28 : 35; int num830 = ModContent.ProjectileType(); - num827 = (float)Math.Sqrt((double)(num825 * num825 + num826 * num826)); + num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); num827 = num828 / num827; num825 *= num827; num826 *= num827; @@ -1492,7 +1451,7 @@ namespace CalamityMod.NPCs else if (npc.ai[1] == 1f) { int num831 = 1; - if (npc.position.X + (float)(npc.width / 2) < player.position.X + (float)player.width) + if (npc.position.X + (npc.width / 2) < player.position.X + player.width) num831 = -1; float num832 = expertMode ? 9.5f : 8f; @@ -1518,10 +1477,10 @@ namespace CalamityMod.NPCs num833 *= 1.5f; } - Vector2 vector83 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num834 = player.position.X + (float)(player.width / 2) + (float)(num831 * (CalamityWorld.bossRushActive ? 460 : 360)) - vector83.X; - float num835 = player.position.Y + (float)(player.height / 2) - vector83.Y; - float num836 = (float)Math.Sqrt((double)(num834 * num834 + num835 * num835)); + Vector2 vector83 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num834 = player.position.X + (player.width / 2) + (num831 * (CalamityWorld.bossRushActive ? 460 : 360)) - vector83.X; + float num835 = player.position.Y + (player.height / 2) - vector83.Y; + float num836 = (float)Math.Sqrt(num834 * num834 + num835 * num835); num836 = num832 / num836; num834 *= num836; num835 *= num836; @@ -1551,8 +1510,8 @@ namespace CalamityMod.NPCs npc.velocity.Y -= num833; } - num834 = player.position.X + (float)(player.width / 2) - vector83.X; - num835 = player.position.Y + (float)(player.height / 2) - vector83.Y; + num834 = player.position.X + (player.width / 2) - vector83.X; + num835 = player.position.Y + (player.height / 2) - vector83.Y; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -1575,7 +1534,7 @@ namespace CalamityMod.NPCs float num837 = CalamityWorld.bossRushActive ? 15f : 11f; int num838 = brotherAlive ? (expertMode ? 34 : 42) : (expertMode ? 28 : 35); int num839 = brotherAlive ? ModContent.ProjectileType() : ModContent.ProjectileType(); - num836 = (float)Math.Sqrt((double)(num834 * num834 + num835 * num835)); + num836 = (float)Math.Sqrt(num834 * num834 + num835 * num835); num836 = num837 / num836; num834 *= num836; num835 *= num836; @@ -1601,7 +1560,7 @@ namespace CalamityMod.NPCs float num837 = CalamityWorld.bossRushActive ? 14f : 10.5f; int num838 = expertMode ? 20 : 24; int num839 = ModContent.ProjectileType(); - num836 = (float)Math.Sqrt((double)(num834 * num834 + num835 * num835)); + num836 = (float)Math.Sqrt(num834 * num834 + num835 * num835); num836 = num837 / num836; num834 *= num836; num835 *= num836; @@ -1649,13 +1608,13 @@ namespace CalamityMod.NPCs if (npc.ai[2] >= chargeTime) { npc.velocity *= 0.93f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) npc.velocity.Y = 0f; } else - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; if (npc.ai[2] >= chargeTime + 15f) { @@ -1691,13 +1650,13 @@ namespace CalamityMod.NPCs } int num408 = 1; - if (npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)Main.player[npc.target].width) + if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) num408 = -1; - Vector2 vector11 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num65 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) + (float)(num62 * num408) - vector11.X; - float num66 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector11.Y; - float num67 = (float)Math.Sqrt((double)(num65 * num65 + num66 * num66)); + Vector2 vector11 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num65 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (num62 * num408) - vector11.X; + float num66 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector11.Y; + float num67 = (float)Math.Sqrt(num65 * num65 + num66 * num66); num67 = num63 / num67; num65 *= num67; @@ -1729,7 +1688,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= 30f) + if (npc.ai[2] >= 45f) { npc.TargetClosest(true); npc.ai[1] = 2f; @@ -1744,7 +1703,7 @@ namespace CalamityMod.NPCs CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); // Emit light - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 1f, 0f, 0f); + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 1f, 0f, 0f); CalamityGlobalNPC.cataclysm = npc.whoAmI; @@ -1759,25 +1718,25 @@ namespace CalamityMod.NPCs Player player = Main.player[npc.target]; - float num840 = npc.position.X + (float)(npc.width / 2) - player.position.X - (float)(player.width / 2); - float num841 = npc.position.Y + (float)npc.height - 59f - player.position.Y - (float)(player.height / 2); - float num842 = (float)Math.Atan2((double)num841, (double)num840) + 1.57f; + float num840 = npc.position.X + (npc.width / 2) - player.position.X - (player.width / 2); + float num841 = npc.position.Y + npc.height - 59f - player.position.Y - (player.height / 2); + float num842 = (float)Math.Atan2(num841, num840) + MathHelper.PiOver2; if (num842 < 0f) - num842 += 6.283f; - else if ((double)num842 > 6.283) - num842 -= 6.283f; + num842 += MathHelper.TwoPi; + else if (num842 > MathHelper.TwoPi) + num842 -= MathHelper.TwoPi; float num843 = 0.15f; if (npc.rotation < num842) { - if ((double)(num842 - npc.rotation) > 3.1415) + if ((num842 - npc.rotation) > MathHelper.Pi) npc.rotation -= num843; else npc.rotation += num843; } else if (npc.rotation > num842) { - if ((double)(npc.rotation - num842) > 3.1415) + if ((npc.rotation - num842) > MathHelper.Pi) npc.rotation += num843; else npc.rotation -= num843; @@ -1786,9 +1745,9 @@ namespace CalamityMod.NPCs if (npc.rotation > num842 - num843 && npc.rotation < num842 + num843) npc.rotation = num842; if (npc.rotation < 0f) - npc.rotation += 6.283f; - else if ((double)npc.rotation > 6.283) - npc.rotation -= 6.283f; + npc.rotation += MathHelper.TwoPi; + else if (npc.rotation > MathHelper.TwoPi) + npc.rotation -= MathHelper.TwoPi; if (npc.rotation > num842 - num843 && npc.rotation < num842 + num843) npc.rotation = num842; @@ -1838,13 +1797,13 @@ namespace CalamityMod.NPCs } int num863 = 1; - if (npc.position.X + (float)(npc.width / 2) < player.position.X + (float)player.width) + if (npc.position.X + (npc.width / 2) < player.position.X + player.width) num863 = -1; - Vector2 vector86 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num864 = player.position.X + (float)(player.width / 2) + (float)(num863 * (CalamityWorld.bossRushActive ? 270 : 180)) - vector86.X; - float num865 = player.position.Y + (float)(player.height / 2) - vector86.Y; - float num866 = (float)Math.Sqrt((double)(num864 * num864 + num865 * num865)); + Vector2 vector86 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num864 = player.position.X + (player.width / 2) + (num863 * (CalamityWorld.bossRushActive ? 270 : 180)) - vector86.X; + float num865 = player.position.Y + (player.height / 2) - vector86.Y; + float num866 = (float)Math.Sqrt(num864 * num864 + num865 * num865); if (expertMode || provy) { @@ -1901,7 +1860,7 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - bool fireDelay = npc.ai[2] > 120f || (double)npc.life < (double)npc.lifeMax * 0.9; + bool fireDelay = npc.ai[2] > 120f || npc.life < npc.lifeMax * 0.9; if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height) && fireDelay) { npc.localAI[2] += 1f; @@ -1923,10 +1882,10 @@ namespace CalamityMod.NPCs float num867 = CalamityWorld.bossRushActive ? 9f : 6f; int num868 = expertMode ? 30 : 38; int num869 = ModContent.ProjectileType(); - vector86 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num864 = player.position.X + (float)(player.width / 2) - vector86.X; - num865 = player.position.Y + (float)(player.height / 2) - vector86.Y; - num866 = (float)Math.Sqrt((double)(num864 * num864 + num865 * num865)); + vector86 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num864 = player.position.X + (player.width / 2) - vector86.X; + num865 = player.position.Y + (player.height / 2) - vector86.Y; + num866 = (float)Math.Sqrt(num864 * num864 + num865 * num865); num866 = num867 / num866; num864 *= num866; num865 *= num866; @@ -1960,10 +1919,10 @@ namespace CalamityMod.NPCs if (CalamityWorld.bossRushActive) num870 *= 1.25f; - Vector2 vector87 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num871 = player.position.X + (float)(player.width / 2) - vector87.X; - float num872 = player.position.Y + (float)(player.height / 2) - vector87.Y; - float num873 = (float)Math.Sqrt((double)(num871 * num871 + num872 * num872)); + Vector2 vector87 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num871 = player.position.X + (player.width / 2) - vector87.X; + float num872 = player.position.Y + (player.height / 2) - vector87.Y; + float num873 = (float)Math.Sqrt(num871 * num871 + num872 * num872); num873 = num870 / num873; npc.velocity.X = num871 * num873; npc.velocity.Y = num872 * num873; @@ -1986,13 +1945,13 @@ namespace CalamityMod.NPCs npc.velocity.X *= 0.93f; npc.velocity.Y *= 0.93f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) npc.velocity.Y = 0f; } else - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; if (npc.ai[2] >= 105f) { @@ -2017,7 +1976,7 @@ namespace CalamityMod.NPCs CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); // Emit light - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 1f, 0f, 0f); + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 1f, 0f, 0f); CalamityGlobalNPC.catastrophe = npc.whoAmI; @@ -2032,25 +1991,25 @@ namespace CalamityMod.NPCs Player player = Main.player[npc.target]; - float num840 = npc.position.X + (float)(npc.width / 2) - player.position.X - (float)(player.width / 2); - float num841 = npc.position.Y + (float)npc.height - 59f - player.position.Y - (float)(player.height / 2); - float num842 = (float)Math.Atan2((double)num841, (double)num840) + 1.57f; + float num840 = npc.position.X + (npc.width / 2) - player.position.X - (player.width / 2); + float num841 = npc.position.Y + npc.height - 59f - player.position.Y - (player.height / 2); + float num842 = (float)Math.Atan2(num841, num840) + MathHelper.PiOver2; if (num842 < 0f) - num842 += 6.283f; - else if ((double)num842 > 6.283) - num842 -= 6.283f; + num842 += MathHelper.TwoPi; + else if (num842 > MathHelper.TwoPi) + num842 -= MathHelper.TwoPi; float num843 = 0.15f; if (npc.rotation < num842) { - if ((double)(num842 - npc.rotation) > 3.1415) + if ((num842 - npc.rotation) > MathHelper.Pi) npc.rotation -= num843; else npc.rotation += num843; } else if (npc.rotation > num842) { - if ((double)(npc.rotation - num842) > 3.1415) + if ((npc.rotation - num842) > MathHelper.Pi) npc.rotation += num843; else npc.rotation -= num843; @@ -2059,9 +2018,9 @@ namespace CalamityMod.NPCs if (npc.rotation > num842 - num843 && npc.rotation < num842 + num843) npc.rotation = num842; if (npc.rotation < 0f) - npc.rotation += 6.283f; - else if ((double)npc.rotation > 6.283) - npc.rotation -= 6.283f; + npc.rotation += MathHelper.TwoPi; + else if (npc.rotation > MathHelper.TwoPi) + npc.rotation -= MathHelper.TwoPi; if (npc.rotation > num842 - num843 && npc.rotation < num842 + num843) npc.rotation = num842; @@ -2111,13 +2070,13 @@ namespace CalamityMod.NPCs } int num863 = 1; - if (npc.position.X + (float)(npc.width / 2) < player.position.X + (float)player.width) + if (npc.position.X + (npc.width / 2) < player.position.X + player.width) num863 = -1; - Vector2 vector86 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num864 = player.position.X + (float)(player.width / 2) + (float)(num863 * (CalamityWorld.bossRushActive ? 270 : 180)) - vector86.X; - float num865 = player.position.Y + (float)(player.height / 2) - vector86.Y; - float num866 = (float)Math.Sqrt((double)(num864 * num864 + num865 * num865)); + Vector2 vector86 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num864 = player.position.X + (player.width / 2) + (num863 * (CalamityWorld.bossRushActive ? 270 : 180)) - vector86.X; + float num865 = player.position.Y + (player.height / 2) - vector86.Y; + float num866 = (float)Math.Sqrt(num864 * num864 + num865 * num865); if (expertMode || provy) { @@ -2174,7 +2133,7 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - bool fireDelay = npc.ai[2] > 120f || (double)npc.life < (double)npc.lifeMax * 0.9; + bool fireDelay = npc.ai[2] > 120f || npc.life < npc.lifeMax * 0.9; if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height) && fireDelay) { npc.localAI[2] += 1f; @@ -2196,10 +2155,10 @@ namespace CalamityMod.NPCs float num867 = CalamityWorld.bossRushActive ? 18f : 12f; int num868 = expertMode ? 29 : 36; int num869 = ModContent.ProjectileType(); - vector86 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num864 = player.position.X + (float)(player.width / 2) - vector86.X; - num865 = player.position.Y + (float)(player.height / 2) - vector86.Y; - num866 = (float)Math.Sqrt((double)(num864 * num864 + num865 * num865)); + vector86 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num864 = player.position.X + (player.width / 2) - vector86.X; + num865 = player.position.Y + (player.height / 2) - vector86.Y; + num866 = (float)Math.Sqrt(num864 * num864 + num865 * num865); num866 = num867 / num866; num864 *= num866; num865 *= num866; @@ -2233,10 +2192,10 @@ namespace CalamityMod.NPCs if (CalamityWorld.bossRushActive) num870 *= 1.25f; - Vector2 vector87 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num871 = player.position.X + (float)(player.width / 2) - vector87.X; - float num872 = player.position.Y + (float)(player.height / 2) - vector87.Y; - float num873 = (float)Math.Sqrt((double)(num871 * num871 + num872 * num872)); + Vector2 vector87 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num871 = player.position.X + (player.width / 2) - vector87.X; + float num872 = player.position.Y + (player.height / 2) - vector87.Y; + float num873 = (float)Math.Sqrt(num871 * num871 + num872 * num872); num873 = num870 / num873; npc.velocity.X = num871 * num873; npc.velocity.Y = num872 * num873; @@ -2259,13 +2218,13 @@ namespace CalamityMod.NPCs npc.velocity.X *= 0.93f; npc.velocity.Y *= 0.93f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) npc.velocity.Y = 0f; } else - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; if (npc.ai[2] >= 90f) //80 { @@ -2294,14 +2253,14 @@ namespace CalamityMod.NPCs CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; // Variables bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; bool death = CalamityWorld.death || CalamityWorld.bossRushActive; int shootBuff = death ? 1 : (int)(2f * (1f - lifeRatio)); - float shootTimer = 1f + ((float)shootBuff); + float shootTimer = 1f + shootBuff; bool dayTime = Main.dayTime; // Get a target @@ -2351,7 +2310,7 @@ namespace CalamityMod.NPCs // Emit light when not Idle if (npc.ai[0] != 1f) - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 1.3f, 0.5f, 0f); + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 1.3f, 0.5f, 0f); // Fire projectiles while walking, teleporting, or falling if (npc.ai[0] == 2f || npc.ai[0] >= 5f || (npc.ai[0] == 4f && npc.velocity.Y > 0f) || @@ -2371,7 +2330,7 @@ namespace CalamityMod.NPCs // Fire astral flames while teleporting if ((npc.ai[0] >= 5f && npc.ai[0] != 7) || calamityGlobalNPC.enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) { - Vector2 shootFromVector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + Vector2 shootFromVector = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float spread = 45f * 0.0174f; double startAngle = Math.Atan2(npc.velocity.X, npc.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; @@ -2392,11 +2351,11 @@ namespace CalamityMod.NPCs else if ((npc.ai[0] == 4f && npc.velocity.Y > 0f && expertMode) || npc.ai[0] == 2f) { float num179 = CalamityWorld.bossRushActive ? 24f : 18.5f; - Vector2 value9 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num180 = player.position.X + (float)player.width * 0.5f - value9.X; + Vector2 value9 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num180 = player.position.X + player.width * 0.5f - value9.X; float num181 = Math.Abs(num180) * 0.1f; - float num182 = player.position.Y + (float)player.height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); + float num182 = player.position.Y + player.height * 0.5f - value9.Y - num181; + float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); npc.netUpdate = true; num183 = num179 / num183; num180 *= num183; @@ -2406,12 +2365,12 @@ namespace CalamityMod.NPCs value9.Y += num182; for (int num186 = 0; num186 < 5; num186++) { - num180 = player.position.X + (float)player.width * 0.5f - value9.X; - num182 = player.position.Y + (float)player.height * 0.5f - value9.Y; - num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); + num180 = player.position.X + player.width * 0.5f - value9.X; + num182 = player.position.Y + player.height * 0.5f - value9.Y; + num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); num183 = num179 / num183; - num180 += (float)Main.rand.Next(-60, 61); - num182 += (float)Main.rand.Next(-60, 61); + num180 += Main.rand.Next(-60, 61); + num182 += Main.rand.Next(-60, 61); num180 *= num183; num182 *= num183; Projectile.NewProjectile(value9.X, value9.Y, num180, num182, num185, laserDamage, 0f, Main.myPlayer, 0f, 0f); @@ -2475,7 +2434,7 @@ namespace CalamityMod.NPCs if (Math.Abs(npc.Center.X - player.Center.X) < 200f) { npc.velocity.X *= 0.9f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; } else @@ -2492,10 +2451,10 @@ namespace CalamityMod.NPCs // Walk through tiles if colliding with tiles and player is out of reach int num854 = 80; int num855 = 20; - Vector2 position2 = new Vector2(npc.Center.X - (float)(num854 / 2), npc.position.Y + (float)npc.height - (float)num855); + Vector2 position2 = new Vector2(npc.Center.X - (num854 / 2), npc.position.Y + npc.height - num855); bool flag52 = false; - if (npc.position.X < player.position.X && npc.position.X + (float)npc.width > player.position.X + (float)player.width && npc.position.Y + (float)npc.height < player.position.Y + (float)player.height - 16f) + if (npc.position.X < player.position.X && npc.position.X + npc.width > player.position.X + player.width && npc.position.Y + npc.height < player.position.Y + player.height - 16f) flag52 = true; if (flag52) @@ -2505,7 +2464,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y > 0f) npc.velocity.Y = 0f; - if ((double)npc.velocity.Y > -0.2) + if (npc.velocity.Y > -0.2) npc.velocity.Y -= 0.025f; else npc.velocity.Y -= 0.2f; @@ -2518,7 +2477,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < 0f) npc.velocity.Y = 0f; - if ((double)npc.velocity.Y < 0.1) + if (npc.velocity.Y < 0.1) npc.velocity.Y += 0.025f; else npc.velocity.Y += 0.5f; @@ -2562,11 +2521,11 @@ namespace CalamityMod.NPCs // Set jump velocity, reset and set AI to next phase (Stomp) float velocityBoost = death ? 6f : 6f * (1f - lifeRatio); float velocityX = (CalamityWorld.bossRushActive ? 9f : 6f) + velocityBoost; - npc.velocity.X = velocityX * (float)npc.direction; + npc.velocity.X = velocityX * npc.direction; if (revenge) { - if (player.position.Y < npc.position.Y + (float)npc.height) + if (player.position.Y < npc.position.Y + npc.height) npc.velocity.Y = -14.5f; else npc.velocity.Y = 1f; @@ -2606,7 +2565,7 @@ namespace CalamityMod.NPCs { for (int num623 = 0; num623 < 4; num623++) { - int num624 = Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y + (float)npc.height), npc.width + 20, 4, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); + int num624 = Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y + npc.height), npc.width + 20, 4, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); Main.dust[num624].velocity *= 0.2f; } } @@ -2615,16 +2574,16 @@ namespace CalamityMod.NPCs { // Set velocities while falling, this happens before the stomp // Fall through - if (npc.target >= 0 && revenge && ((player.position.Y > npc.position.Y + (float)npc.height && npc.velocity.Y > 0f) || (player.position.Y < npc.position.Y + (float)npc.height && npc.velocity.Y < 0f))) + if (npc.target >= 0 && revenge && ((player.position.Y > npc.position.Y + npc.height && npc.velocity.Y > 0f) || (player.position.Y < npc.position.Y + npc.height && npc.velocity.Y < 0f))) npc.noTileCollide = true; else npc.noTileCollide = false; - if (npc.position.X < player.position.X && npc.position.X + (float)npc.width > player.position.X + (float)player.width) + if (npc.position.X < player.position.X && npc.position.X + npc.width > player.position.X + player.width) { npc.velocity.X *= 0.9f; - if (player.position.Y > npc.position.Y + (float)npc.height) + if (player.position.Y > npc.position.Y + npc.height) { float fallSpeedBoost = death ? 0.8f : 0.8f * (1f - lifeRatio); float fallSpeed = 0.8f + fallSpeedBoost; @@ -2685,7 +2644,7 @@ namespace CalamityMod.NPCs num1250 += Main.rand.Next(-30, 31); num1251 += Main.rand.Next(-30, 31); - if (!WorldGen.SolidTile(num1250, num1251) && Collision.CanHit(new Vector2((float)(num1250 * 16), (float)(num1251 * 16)), 1, 1, player.position, player.width, player.height)) + if (!WorldGen.SolidTile(num1250, num1251) && Collision.CanHit(new Vector2(num1250 * 16, num1251 * 16), 1, 1, player.position, player.width, player.height)) break; if (num1249 > 100) @@ -2694,8 +2653,8 @@ namespace CalamityMod.NPCs // Set AI to next phase (Mid-teleport), set AI 2 and 3 to teleport coordinates X and Y respectively npc.ai[0] = 6f; - npc.ai[2] = (float)num1250; - npc.ai[3] = (float)num1251; + npc.ai[2] = num1250; + npc.ai[3] = num1251; npc.netUpdate = true; Block: ; @@ -2715,8 +2674,8 @@ namespace CalamityMod.NPCs if (npc.alpha >= 255) { // Set position to teleport destination - npc.position.X = npc.ai[2] * 16f - (float)(npc.width / 2); - npc.position.Y = npc.ai[3] * 16f - (float)(npc.height / 2); + npc.position.X = npc.ai[2] * 16f - (npc.width / 2); + npc.position.Y = npc.ai[3] * 16f - (npc.height / 2); // Reset alpha and set AI to next phase (End of teleport) npc.alpha = 255; @@ -2797,9 +2756,10 @@ namespace CalamityMod.NPCs bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; bool death = CalamityWorld.death || CalamityWorld.bossRushActive; + bool enraged = calamityGlobalNPC.enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive); // Emit light - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); // Dust and alpha effects if (head || Main.npc[(int)npc.ai[1]].alpha < 128) @@ -2889,9 +2849,9 @@ namespace CalamityMod.NPCs Main.npc[lol].localAI[3] = 1f; Main.npc[lol].realLife = npc.whoAmI; - Main.npc[lol].ai[2] = (float)npc.whoAmI; - Main.npc[lol].ai[1] = (float)Previous; - Main.npc[Previous].ai[0] = (float)lol; + Main.npc[lol].ai[2] = npc.whoAmI; + Main.npc[lol].ai[1] = Previous; + Main.npc[Previous].ai[0] = lol; NetMessage.SendData(23, -1, -1, null, lol, 0f, 0f, 0f, 0); Previous = lol; } @@ -2935,7 +2895,7 @@ namespace CalamityMod.NPCs // Calculate phases based on worm HP int astrumDeusTotalHP = 0; - double mainDeusHPRatio = (double)npc.life / (double)npc.lifeMax; + double mainDeusHPRatio = npc.life / (double)npc.lifeMax; if (calamityGlobalNPC.newAI[0] == 1f) { for (int i = 0; i < Main.maxNPCs; i++) @@ -2946,12 +2906,12 @@ namespace CalamityMod.NPCs if (calamityGlobalNPC.newAI[2] < 10f) { calamityGlobalNPC.newAI[2] += 1f; - calamityGlobalNPC.newAI[3] += (float)Main.npc[i].lifeMax; + calamityGlobalNPC.newAI[3] += Main.npc[i].lifeMax; } } } - double astrumDeusHPRatio = (double)astrumDeusTotalHP / (double)calamityGlobalNPC.newAI[3]; + double astrumDeusHPRatio = astrumDeusTotalHP / calamityGlobalNPC.newAI[3]; if (astrumDeusHPRatio < 0.33) { if (mainDeusHPRatio > 0.33) @@ -2990,9 +2950,9 @@ namespace CalamityMod.NPCs float num188 = 10f + speedBoost; float num189 = 0.2f + turnSpeedBoost; - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = player.position.X + (float)(player.width / 2); - float num192 = player.position.Y + (float)(player.height / 2); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = player.position.X + (player.width / 2); + float num192 = player.position.Y + (player.height / 2); int num42 = -1; int num43 = (int)(player.Center.X / 16f); @@ -3029,30 +2989,15 @@ namespace CalamityMod.NPCs } } - for (int num52 = 0; num52 < Main.maxNPCs; num52++) - { - if (Main.npc[num52].active && Main.npc[num52].type == npc.type && num52 != npc.whoAmI) - { - Vector2 vector4 = Main.npc[num52].Center - npc.Center; - if (vector4.Length() < 60f) - { - vector4.Normalize(); - vector4 *= 200f; - num191 -= vector4.X; - num192 -= vector4.Y; - } - } - } - - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; num191 -= vector18.X; num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - float num196 = System.Math.Abs(num191); - float num197 = System.Math.Abs(num192); + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + float num196 = Math.Abs(num191); + float num197 = Math.Abs(num192); float num198 = num188 / num193; num191 *= num198; num192 *= num198; @@ -3079,7 +3024,7 @@ namespace CalamityMod.NPCs npc.velocity.Y -= num189; } - if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) + if (Math.Abs(num192) < num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) { if (npc.velocity.Y > 0f) npc.velocity.Y += num189 * 2f; @@ -3087,7 +3032,7 @@ namespace CalamityMod.NPCs npc.velocity.Y -= num189 * 2f; } - if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) + if (Math.Abs(num191) < num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) { if (npc.velocity.X > 0f) npc.velocity.X += num189 * 2f; @@ -3104,7 +3049,7 @@ namespace CalamityMod.NPCs else if (npc.velocity.X > num191) npc.velocity.X -= num189 * 1.1f; - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) { if (npc.velocity.Y > 0f) npc.velocity.Y += num189; @@ -3119,7 +3064,7 @@ namespace CalamityMod.NPCs else if (npc.velocity.Y > num192) npc.velocity.Y -= num189 * 1.1f; - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) { if (npc.velocity.X > 0f) npc.velocity.X += num189; @@ -3128,7 +3073,7 @@ namespace CalamityMod.NPCs } } } - npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; } // Only the main worm body and tail use this code @@ -3145,16 +3090,16 @@ namespace CalamityMod.NPCs if (npc.type == ModContent.NPCType() && Main.netMode != NetmodeID.MultiplayerClient) { int shootTime = 4; - if ((double)npc.life <= (double)npc.lifeMax * 0.65 || death || player.gravDir == -1f) + if (npc.life <= npc.lifeMax * 0.65 || death || player.gravDir == -1f) { shootTime += death ? 4 : 2; } - if ((double)npc.life <= (double)npc.lifeMax * 0.3 || death || player.gravDir == -1f) + if (npc.life <= npc.lifeMax * 0.3 || death || player.gravDir == -1f) { shootTime += death ? 6 : 2; } - npc.localAI[0] += (float)Main.rand.Next(shootTime); - if (npc.localAI[0] >= (float)Main.rand.Next(1400, 20000)) + npc.localAI[0] += Main.rand.Next(shootTime); + if (npc.localAI[0] >= Main.rand.Next(1400, 20000)) { npc.localAI[0] = 0f; npc.TargetClosest(true); @@ -3173,10 +3118,10 @@ namespace CalamityMod.NPCs { num941 *= 2f; } - Vector2 vector104 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)(npc.height / 2)); - float num942 = player.position.X + (float)player.width * 0.5f - vector104.X; - float num943 = player.position.Y + (float)player.height * 0.5f - vector104.Y; - float num944 = (float)Math.Sqrt((double)(num942 * num942 + num943 * num943)); + Vector2 vector104 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + (npc.height / 2)); + float num942 = player.position.X + player.width * 0.5f - vector104.X; + float num943 = player.position.Y + player.height * 0.5f - vector104.Y; + float num944 = (float)Math.Sqrt(num942 * num942 + num943 * num943); num944 = num941 / num944; num942 *= num944; num943 *= num944; @@ -3191,33 +3136,33 @@ namespace CalamityMod.NPCs } // Follow the head - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = player.position.X + (float)(player.width / 2); - float num192 = player.position.Y + (float)(player.height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = player.position.X + (player.width / 2); + float num192 = player.position.Y + (player.height / 2); + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; num191 -= vector18.X; num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; + num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; } catch { } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + npc.rotation = (float)Math.Atan2(num192, num191) + MathHelper.PiOver2; + num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; + num193 = (num193 - num194) / num193; num191 *= num193; num192 *= num193; npc.velocity = Vector2.Zero; @@ -3246,7 +3191,7 @@ namespace CalamityMod.NPCs } // Life remaining - float deusHPRatio = (float)npc.life / (float)npc.lifeMax; + float deusHPRatio = npc.life / (float)npc.lifeMax; // Only the smaller worm heads use this code if (head) @@ -3296,9 +3241,9 @@ namespace CalamityMod.NPCs // Movement variables int num180 = (int)(npc.position.X / 16f) - 1; - int num181 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; + int num181 = (int)((npc.position.X + npc.width) / 16f) + 2; int num182 = (int)(npc.position.Y / 16f) - 1; - int num183 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; + int num183 = (int)((npc.position.Y + npc.height) / 16f) + 2; if (num180 < 0) num180 = 0; @@ -3316,12 +3261,12 @@ namespace CalamityMod.NPCs { for (int num953 = num182; num953 < num183; num953++) { - if (Main.tile[num952, num953] != null && ((Main.tile[num952, num953].nactive() && (Main.tileSolid[(int)Main.tile[num952, num953].type] || (Main.tileSolidTop[(int)Main.tile[num952, num953].type] && Main.tile[num952, num953].frameY == 0))) || Main.tile[num952, num953].liquid > 64)) + if (Main.tile[num952, num953] != null && ((Main.tile[num952, num953].nactive() && (Main.tileSolid[Main.tile[num952, num953].type] || (Main.tileSolidTop[Main.tile[num952, num953].type] && Main.tile[num952, num953].frameY == 0))) || Main.tile[num952, num953].liquid > 64)) { Vector2 vector105; - vector105.X = (float)(num952 * 16); - vector105.Y = (float)(num953 * 16); - if (npc.position.X + (float)npc.width > vector105.X && npc.position.X < vector105.X + 16f && npc.position.Y + (float)npc.height > vector105.Y && npc.position.Y < vector105.Y + 16f) + vector105.X = num952 * 16; + vector105.Y = num953 * 16; + if (npc.position.X + npc.width > vector105.X && npc.position.X < vector105.X + 16f && npc.position.Y + npc.height > vector105.Y && npc.position.Y < vector105.Y + 16f) { flies = true; break; @@ -3335,8 +3280,15 @@ namespace CalamityMod.NPCs { npc.localAI[1] = 1f; Rectangle rectangle12 = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int rectX = 300; - int rectY = (calamityGlobalNPC.enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) ? 100 : 200; + + int rectX = (int)(600f * deusHPRatio); + if (rectX < 200) + rectX = 200; + + int rectY = (int)(enraged ? 200f : 400f * deusHPRatio); + if (rectY < (enraged ? 75 : 150)) + rectY = enraged ? 75 : 150; + bool flag95 = true; if (npc.position.Y > player.position.Y) { @@ -3362,16 +3314,33 @@ namespace CalamityMod.NPCs // Velocity float num188 = newSpeed; float num189 = newTurnSpeed; - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = player.position.X + (float)(player.width / 2); - float num192 = player.position.Y + (float)(player.height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = player.position.X + (player.width / 2); + float num192 = player.position.Y + (player.height / 2); + + // Spread the worms out based on proximity to other worms + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == npc.type && i != npc.whoAmI) + { + Vector2 vector = Main.npc[i].Center - npc.Center; + if (vector.Length() < 80f) + { + vector.Normalize(); + vector *= 300f; + num191 -= vector.X; + num192 -= vector.Y; + } + } + } + + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; num191 -= vector18.X; num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); if (!flies) { @@ -3381,7 +3350,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y > maxSpeed) npc.velocity.Y = maxSpeed; - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)maxSpeed * 0.4) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < maxSpeed * 0.4) { if (npc.velocity.X < 0f) npc.velocity.X -= num188 * 1.1f; @@ -3417,9 +3386,9 @@ namespace CalamityMod.NPCs Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 1); } - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - float num196 = System.Math.Abs(num191); - float num197 = System.Math.Abs(num192); + num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + float num196 = Math.Abs(num191); + float num197 = Math.Abs(num192); float num198 = maxSpeed / num193; num191 *= num198; num192 *= num198; @@ -3459,7 +3428,7 @@ namespace CalamityMod.NPCs npc.velocity.Y -= num188; } - if ((double)System.Math.Abs(num192) < (double)maxSpeed * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) + if (Math.Abs(num192) < maxSpeed * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) { if (npc.velocity.Y > 0f) npc.velocity.Y += num188 * 2f; @@ -3467,7 +3436,7 @@ namespace CalamityMod.NPCs npc.velocity.Y -= num188 * 2f; } - if ((double)System.Math.Abs(num191) < (double)maxSpeed * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) + if (Math.Abs(num191) < maxSpeed * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) { if (npc.velocity.X > 0f) npc.velocity.X += num188 * 2f; @@ -3484,7 +3453,7 @@ namespace CalamityMod.NPCs else if (npc.velocity.X > num191) npc.velocity.X -= num188 * 1.1f; - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)maxSpeed * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < maxSpeed * 0.5) { if (npc.velocity.Y > 0f) npc.velocity.Y += num188; @@ -3499,7 +3468,7 @@ namespace CalamityMod.NPCs else if (npc.velocity.Y > num192) npc.velocity.Y -= num188 * 1.1f; - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)maxSpeed * 0.5) + if ((Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < maxSpeed * 0.5) { if (npc.velocity.X > 0f) npc.velocity.X += num188; @@ -3509,7 +3478,7 @@ namespace CalamityMod.NPCs } } - npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; if (flies) { @@ -3546,7 +3515,7 @@ namespace CalamityMod.NPCs calamityGlobalNPC.unbreakableDR = true; } - double lifeRatio = (double)npc.life / (double)npc.lifeMax; + double lifeRatio = npc.life / (double)npc.lifeMax; int lifePercentage = (int)(100.0 * lifeRatio); bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; @@ -3612,7 +3581,7 @@ namespace CalamityMod.NPCs npc.ai[0] = 0f; int numDust = (int)(0.2f * MathHelper.TwoPi * num474); - float angleIncrement = MathHelper.TwoPi / (float)numDust; + float angleIncrement = MathHelper.TwoPi / numDust; Vector2 dustOffset = new Vector2(num474, 0f); dustOffset = dustOffset.RotatedByRandom(MathHelper.TwoPi); @@ -3631,9 +3600,9 @@ namespace CalamityMod.NPCs { if (Collision.CanHit(npc.Center, 1, 1, Main.player[num475].Center, 1, 1)) { - float num476 = Main.player[num475].position.X + (float)(Main.player[num475].width / 2); - float num477 = Main.player[num475].position.Y + (float)(Main.player[num475].height / 2); - float num478 = Math.Abs(npc.position.X + (float)(npc.width / 2) - num476) + Math.Abs(npc.position.Y + (float)(npc.height / 2) - num477); + float num476 = Main.player[num475].position.X + (Main.player[num475].width / 2); + float num477 = Main.player[num475].position.Y + (Main.player[num475].height / 2); + float num478 = Math.Abs(npc.position.X + (npc.width / 2) - num476) + Math.Abs(npc.position.Y + (npc.height / 2) - num477); if (num478 < num474) { @@ -3664,10 +3633,10 @@ namespace CalamityMod.NPCs if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) { float num941 = 3f; - Vector2 vector104 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)(npc.height / 2)); - float num942 = player.position.X + (float)player.width * 0.5f - vector104.X + (float)Main.rand.Next(-20, 21); - float num943 = player.position.Y + (float)player.height * 0.5f - vector104.Y + (float)Main.rand.Next(-20, 21); - float num944 = (float)Math.Sqrt((double)(num942 * num942 + num943 * num943)); + Vector2 vector104 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + (npc.height / 2)); + float num942 = player.position.X + player.width * 0.5f - vector104.X + Main.rand.Next(-20, 21); + float num943 = player.position.Y + player.height * 0.5f - vector104.Y + Main.rand.Next(-20, 21); + float num944 = (float)Math.Sqrt(num942 * num942 + num943 * num943); num944 = num941 / num944; num942 *= num944; num943 *= num944; @@ -3688,7 +3657,7 @@ namespace CalamityMod.NPCs for (int i = 0; i < 12; i++) { float ai1 = player.ZoneDungeon ? 0f : 1f; - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, (float)(i * 30), ai1); + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, i * 30, ai1); } } else @@ -3716,10 +3685,10 @@ namespace CalamityMod.NPCs if (!player.ZoneDungeon || CalamityWorld.bossRushActive) num823 = 25f; - Vector2 vector82 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num825 = player.position.X + (float)(player.width / 2) - vector82.X; - float num826 = player.position.Y + (float)(player.height / 2) - vector82.Y; - float num827 = (float)Math.Sqrt((double)(num825 * num825 + num826 * num826)); + Vector2 vector82 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num825 = player.position.X + (player.width / 2) - vector82.X; + float num826 = player.position.Y + (player.height / 2) - vector82.Y; + float num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); num827 = num823 / num827; num825 *= num827; @@ -3751,16 +3720,16 @@ namespace CalamityMod.NPCs } if (calamityGlobalNPC.newAI[0] == 0f && npc.life > 0) - calamityGlobalNPC.newAI[0] = (float)npc.lifeMax; + calamityGlobalNPC.newAI[0] = npc.lifeMax; if (npc.life > 0) { if (Main.netMode != NetmodeID.MultiplayerClient) { - int num660 = (int)((double)npc.lifeMax * 0.26); - if ((float)(npc.life + num660) < calamityGlobalNPC.newAI[0]) + int num660 = (int)(npc.lifeMax * 0.26); + if ((npc.life + num660) < calamityGlobalNPC.newAI[0]) { - calamityGlobalNPC.newAI[0] = (float)npc.life; + calamityGlobalNPC.newAI[0] = npc.life; calamityGlobalNPC.newAI[2] += 1f; int glob = revenge ? 8 : 4; if (calamityGlobalNPC.newAI[0] <= 0.5f) @@ -3833,7 +3802,7 @@ namespace CalamityMod.NPCs npc.timeLeft = 1800; // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; // Phases bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f) || death; @@ -4038,7 +4007,7 @@ namespace CalamityMod.NPCs if (phase2) { Main.PlaySound(SoundID.Item102, (int)npc.position.X, (int)npc.position.Y); - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Main.rand.Next(-2, 3), -4f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, Main.rand.Next(-2, 3), -4f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); } } else if (NPC.CountNPCS(ModContent.NPCType()) < num1305) @@ -4051,7 +4020,7 @@ namespace CalamityMod.NPCs featherAmt *= 2; for (int num186 = 0; num186 < featherAmt; num186++) { - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Main.rand.Next(-4, 5), -3f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, Main.rand.Next(-4, 5), -3f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); } } } @@ -4224,14 +4193,14 @@ namespace CalamityMod.NPCs npc.ai[0] = 3.2f; npc.ai[1] = 0f; - npc.ai[1] = (float)npc.direction; + npc.ai[1] = npc.direction; } } // Charge else if (npc.ai[0] == 3.2f) { - npc.damage = (int)((double)npc.defDamage * 1.5); + npc.damage = (int)(npc.defDamage * 1.5); npc.collideX = false; npc.collideY = false; @@ -4286,14 +4255,14 @@ namespace CalamityMod.NPCs if (!WorldGen.SolidTile(num1313, num1314)) { - while (!WorldGen.SolidTile(num1313, num1314) && (double)num1314 < Main.worldSurface) + while (!WorldGen.SolidTile(num1313, num1314) && num1314 < Main.worldSurface) num1314++; - if ((new Vector2((float)(num1313 * 16 + 8), (float)(num1314 * 16 + 8)) - player.Center).Length() < 1200f) + if ((new Vector2(num1313 * 16 + 8, num1314 * 16 + 8) - player.Center).Length() < 1200f) { npc.ai[0] = 4.1f; - npc.ai[1] = (float)num1313; - npc.ai[2] = (float)num1314; + npc.ai[1] = num1313; + npc.ai[2] = num1314; break; } } @@ -4319,8 +4288,8 @@ namespace CalamityMod.NPCs int num1317 = (int)npc.ai[1]; int num1318 = (int)npc.ai[2]; - float x2 = (float)(num1317 * 16 + 8); - float y2 = (float)(num1318 * 16 - 20); + float x2 = num1317 * 16 + 8; + float y2 = num1318 * 16 - 20; Vector2 vector207 = new Vector2(x2, y2); vector207 -= npc.Center; @@ -4347,8 +4316,8 @@ namespace CalamityMod.NPCs int num1321 = (int)npc.ai[1]; int num1322 = (int)npc.ai[2]; - float x3 = (float)(num1321 * 16 + 8); - float y3 = (float)(num1322 * 16 - 20); + float x3 = num1321 * 16 + 8; + float y3 = num1322 * 16 - 20; Vector2 vector208 = new Vector2(x3, y3); vector208 -= npc.Center; @@ -4360,10 +4329,10 @@ namespace CalamityMod.NPCs { int num1325 = 10; if (Main.expertMode) - num1325 = (int)((double)num1325 * 0.75); + num1325 = (int)(num1325 * 0.75); npc.ai[3] += 1f; - if (npc.ai[3] == (float)num1325) + if (npc.ai[3] == num1325) { SoundEffectInstance sound = Main.PlaySound(SoundID.DD2_BetsySummon, (int)npc.position.X, (int)npc.position.Y); if (sound != null) @@ -4373,7 +4342,7 @@ namespace CalamityMod.NPCs NPC.NewNPC(num1321 * 16 + 8, num1322 * 16, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); } - else if (npc.ai[3] == (float)(num1325 * 2)) + else if (npc.ai[3] == num1325 * 2) { npc.TargetClosest(true); npc.ai[0] = 0f; @@ -4412,8 +4381,8 @@ 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, phase3 ? 1f : 0f, (float)(npc.target + 1)); + Vector2 vector7 = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + vector; + Projectile.NewProjectile(vector7.X, vector7.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, phase3 ? 1f : 0f, npc.target + 1); } } @@ -4437,8 +4406,8 @@ namespace CalamityMod.NPCs bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; bool death = CalamityWorld.death || CalamityWorld.bossRushActive; - bool phase2 = (double)npc.life <= (double)npc.lifeMax * (revenge ? 0.7 : 0.5) || death; - bool phase3 = (double)npc.life <= (double)npc.lifeMax * (death ? 0.5 : (revenge ? 0.35 : 0.2)) && expertMode; + bool phase2 = npc.life <= npc.lifeMax * (revenge ? 0.7 : 0.5) || death; + bool phase3 = npc.life <= npc.lifeMax * (death ? 0.5 : (revenge ? 0.35 : 0.2)) && expertMode; bool phase2AI = npc.ai[0] > 4f; bool phase3AI = npc.ai[0] > 9f; bool charging = npc.ai[3] < 10f; @@ -4463,11 +4432,11 @@ namespace CalamityMod.NPCs npc.defense = calamityGlobalNPC.newAI[1] == 1f ? npc.defDefense / 4 : npc.defDefense; if (phase3AI) { - npc.damage = (int)((float)npc.defDamage * 1.32f); + npc.damage = (int)(npc.defDamage * 1.32f); } else if (phase2AI) { - npc.damage = (int)((float)npc.defDamage * 1.44f); + npc.damage = (int)(npc.defDamage * 1.44f); } else { @@ -4541,7 +4510,7 @@ namespace CalamityMod.NPCs int num12 = 30; int num13 = 120; int num14 = 24; - float spinTime = (float)(num13 / 2); + float spinTime = num13 / 2; float scaleFactor3 = 9f; float scaleFactor4 = 22f; float num15 = MathHelper.TwoPi / spinTime; @@ -4585,8 +4554,8 @@ namespace CalamityMod.NPCs // Enrage variable bool enrage = !CalamityWorld.bossRushActive && - (player.position.Y < 300f || (double)player.position.Y > Main.worldSurface * 16.0 || - (player.position.X > 7200f && player.position.X < (float)(Main.maxTilesX * 16 - 7200))); + (player.position.Y < 300f || player.position.Y > Main.worldSurface * 16.0 || + (player.position.X > 7200f && player.position.X < (Main.maxTilesX * 16 - 7200))); // If the player isn't in the ocean biome or Old Duke is transitioning between phases, become immune if (!phase3AI) @@ -4616,7 +4585,7 @@ namespace CalamityMod.NPCs } // Rotation - float num17 = (float)Math.Atan2((double)(player.Center.Y - vector.Y), (double)(player.Center.X - vector.X)); + float num17 = (float)Math.Atan2(player.Center.Y - vector.Y, player.Center.X - vector.X); if (npc.spriteDirection == 1) num17 += pie; if (num17 < 0f) @@ -4710,12 +4679,12 @@ namespace CalamityMod.NPCs } // Spawn dust and play sound - if (npc.ai[2] == (float)(num9 - 30)) + if (npc.ai[2] == num9 - 30) { int num20 = 36; for (int i = 0; i < num20; i++) { - Vector2 dust = (Vector2.Normalize(npc.velocity) * new Vector2((float)npc.width / 2f, (float)npc.height) * 0.75f * 0.5f).RotatedBy((double)((float)(i - (num20 / 2 - 1)) * MathHelper.TwoPi / (float)num20), default) + npc.Center; + Vector2 dust = (Vector2.Normalize(npc.velocity) * new Vector2(npc.width / 2f, npc.height) * 0.75f * 0.5f).RotatedBy((i - (num20 / 2 - 1)) * MathHelper.TwoPi / num20) + npc.Center; Vector2 vector2 = dust - npc.Center; int num21 = Dust.NewDust(dust + vector2, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, vector2.X * 2f, vector2.Y * 2f, 100, default, 1.4f); Main.dust[num21].noGravity = true; @@ -4727,7 +4696,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num16) + if (npc.ai[2] >= num16) { npc.ai[0] = 0f; npc.ai[1] = 0f; @@ -4741,7 +4710,7 @@ namespace CalamityMod.NPCs { // Velocity if (npc.ai[1] == 0f) - npc.ai[1] = (float)(500 * Math.Sign((vector - player.Center).X)); + npc.ai[1] = 500 * Math.Sign((vector - player.Center).X); Vector2 vector3 = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -300f) - vector - npc.velocity) * scaleFactor; if (npc.velocity.X < vector3.X) @@ -4788,7 +4757,7 @@ namespace CalamityMod.NPCs if (calamityGlobalNPC.newAI[1] != 1f || (phase2 && !phase2AI)) { npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num2 || (phase2 && !phase2AI)) + if (npc.ai[2] >= num2 || (phase2 && !phase2AI)) { int num23 = 0; switch ((int)npc.ai[3]) @@ -4824,7 +4793,7 @@ namespace CalamityMod.NPCs // Velocity Vector2 distanceVector = player.Center + player.velocity * 20f - vector; npc.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction if (num22 != 0) @@ -4877,8 +4846,8 @@ namespace CalamityMod.NPCs int num24 = 7; 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) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); + Vector2 arg_E1C_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((j - (num24 / 2 - 1)) * pie / num24) + vector; + Vector2 vector4 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * 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; @@ -4887,7 +4856,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)chargeTime) + if (npc.ai[2] >= chargeTime) { calamityGlobalNPC.newAI[0] += 30f; npc.ai[0] = 0f; @@ -4903,7 +4872,7 @@ namespace CalamityMod.NPCs { // Velocity if (npc.ai[1] == 0f) - npc.ai[1] = (float)(500 * Math.Sign((vector - player.Center).X)); + npc.ai[1] = 500 * Math.Sign((vector - player.Center).X); Vector2 vector5 = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -300f) - vector - npc.velocity) * scaleFactor2; if (npc.velocity.X < vector5.X) @@ -4935,14 +4904,14 @@ namespace CalamityMod.NPCs if (npc.ai[2] == 0f) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeRoar"), (int)npc.position.X, (int)npc.position.Y); - if (npc.ai[2] % (float)num7 == 0f) + if (npc.ai[2] % num7 == 0f) { if (npc.ai[2] % 40f == 0f && npc.ai[2] != 0f) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeVomit"), (int)npc.position.X, (int)npc.position.Y); if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector6 = Vector2.Normalize(player.Center - vector) * (float)(npc.width + 20) / 2f + vector; + Vector2 vector6 = Vector2.Normalize(player.Center - vector) * (npc.width + 20) / 2f + vector; NPC.NewNPC((int)vector6.X, (int)vector6.Y + 45, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); } } @@ -4958,7 +4927,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num6) + if (npc.ai[2] >= num6) { calamityGlobalNPC.newAI[0] += 30f; npc.ai[0] = 0f; @@ -4976,21 +4945,21 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Play sound and spawn sharks - if (npc.ai[2] == (float)(num9 - 30)) + if (npc.ai[2] == num9 - 30) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeVomit"), (int)npc.position.X, (int)npc.position.Y); - if (npc.ai[2] >= (float)(num9 - 90)) + if (npc.ai[2] >= num9 - 90) { if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % 18f == 0f) { calamityGlobalNPC.newAI[2] += 100f; - NPC.NewNPC((int)(vector.X + 900f), (int)(vector.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, (float)npc.whoAmI, 0f, 255); - NPC.NewNPC((int)(vector.X - 900f), (int)(vector.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, (float)npc.whoAmI, 0f, 255); + NPC.NewNPC((int)(vector.X + 900f), (int)(vector.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + NPC.NewNPC((int)(vector.X - 900f), (int)(vector.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); } } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num9) + if (npc.ai[2] >= num9) { calamityGlobalNPC.newAI[0] += 30f; calamityGlobalNPC.newAI[2] = 0f; @@ -5009,10 +4978,10 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Sound - if (npc.ai[2] == (float)(num10 - 60)) + if (npc.ai[2] == num10 - 60) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeRoar"), (int)npc.position.X, (int)npc.position.Y); - if (npc.ai[2] >= (float)(num10 - 60)) + if (npc.ai[2] >= num10 - 60) { if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % 18f == 0f) { @@ -5023,7 +4992,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num10) + if (npc.ai[2] >= num10) { calamityGlobalNPC.newAI[0] = 0f; calamityGlobalNPC.newAI[1] = 0f; @@ -5041,7 +5010,7 @@ namespace CalamityMod.NPCs { // Velocity if (npc.ai[1] == 0f) - npc.ai[1] = (float)(500 * Math.Sign((vector - player.Center).X)); + npc.ai[1] = 500 * Math.Sign((vector - player.Center).X); Vector2 vector8 = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -300f) - vector - npc.velocity) * scaleFactor; if (npc.velocity.X < vector8.X) @@ -5088,7 +5057,7 @@ namespace CalamityMod.NPCs if (calamityGlobalNPC.newAI[1] != 1f || (phase3 && !phase3AI)) { npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num2 || (phase3 && !phase3AI)) + if (npc.ai[2] >= num2 || (phase3 && !phase3AI)) { int num28 = 0; switch ((int)npc.ai[3]) @@ -5122,7 +5091,7 @@ namespace CalamityMod.NPCs // Velocity and rotation Vector2 distanceVector = player.Center + player.velocity * 20f - vector; npc.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction if (num27 != 0) @@ -5141,7 +5110,7 @@ namespace CalamityMod.NPCs { // Velocity and rotation npc.velocity = Vector2.Normalize(player.Center - vector) * scaleFactor4; - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction if (num27 != 0) @@ -5189,8 +5158,8 @@ namespace CalamityMod.NPCs int num29 = 7; 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) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); + Vector2 arg_1A97_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((k - (num29 / 2 - 1)) * pie / num29) + vector; + Vector2 vector9 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * 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; @@ -5199,7 +5168,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)chargeTime) + if (npc.ai[2] >= chargeTime) { calamityGlobalNPC.newAI[0] += 30f; npc.ai[0] = 5f; @@ -5219,35 +5188,35 @@ namespace CalamityMod.NPCs Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeRoar"), (int)npc.position.X, (int)npc.position.Y); int damage = expertMode ? 100 : 140; - Vector2 vortexSpawn = vector + npc.velocity.RotatedBy(MathHelper.PiOver2 * -(float)npc.direction) * spinTime / MathHelper.TwoPi; + Vector2 vortexSpawn = vector + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / MathHelper.TwoPi; if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(vortexSpawn.X, vortexSpawn.Y, 0f, 0f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); } } - if (npc.ai[2] % (float)num14 == 0f) + if (npc.ai[2] % num14 == 0f) { if (npc.ai[2] % 45f == 0f && npc.ai[2] != 0f) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeVomit"), (int)npc.position.X, (int)npc.position.Y); if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector10 = Vector2.Normalize(npc.velocity) * (float)(npc.width + 20) / 2f + vector; + Vector2 vector10 = Vector2.Normalize(npc.velocity) * (npc.width + 20) / 2f + vector; int num31 = NPC.NewNPC((int)vector10.X, (int)vector10.Y + 45, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); Main.npc[num31].target = npc.target; - Main.npc[num31].velocity = Vector2.Normalize(npc.velocity).RotatedBy((double)(1.57079637f * (float)npc.direction), default) * scaleFactor3; + Main.npc[num31].velocity = Vector2.Normalize(npc.velocity).RotatedBy(MathHelper.PiOver2 * npc.direction) * scaleFactor3; Main.npc[num31].netUpdate = true; - Main.npc[num31].ai[3] = (float)Main.rand.Next(30, 181); + Main.npc[num31].ai[3] = Main.rand.Next(30, 181); } } // Velocity and rotation - npc.velocity = npc.velocity.RotatedBy((double)(-(double)num15 * (float)npc.direction), default); - npc.rotation -= num15 * (float)npc.direction; + npc.velocity = npc.velocity.RotatedBy(-(double)num15 * (float)npc.direction); + npc.rotation -= num15 * npc.direction; npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num13) + if (npc.ai[2] >= num13) { calamityGlobalNPC.newAI[0] += 30f; npc.ai[0] = 5f; @@ -5265,36 +5234,36 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Play sound - if (npc.ai[2] == (float)(num9 - 30)) + if (npc.ai[2] == num9 - 30) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeVomit"), (int)npc.position.X, (int)npc.position.Y); if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector7 = npc.rotation.ToRotationVector2() * (Vector2.UnitX * (float)npc.direction) * (float)(npc.width + 20) / 2f + vector; + Vector2 vector7 = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + vector; int damage = expertMode ? 55 : 70; for (int i = 0; i < 20; i++) { - float velocityX = (float)(npc.direction * 6) * (Main.rand.NextFloat() + 0.5f); + float velocityX = npc.direction * 6 * (Main.rand.NextFloat() + 0.5f); float velocityY = 8f * (Main.rand.NextFloat() + 0.5f); Projectile.NewProjectile(vector7.X, vector7.Y, velocityX, -velocityY, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); } } } - if (npc.ai[2] >= (float)(num9 - 90)) + if (npc.ai[2] >= num9 - 90) { if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % 18f == 0f) { calamityGlobalNPC.newAI[2] += 100f; float x = 900f - calamityGlobalNPC.newAI[2]; - NPC.NewNPC((int)(vector.X + x), (int)(vector.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, (float)npc.whoAmI, 0f, 255); - NPC.NewNPC((int)(vector.X - x), (int)(vector.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, (float)npc.whoAmI, 0f, 255); + NPC.NewNPC((int)(vector.X + x), (int)(vector.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + NPC.NewNPC((int)(vector.X - x), (int)(vector.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); } } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num9) + if (npc.ai[2] >= num9) { calamityGlobalNPC.newAI[0] += 30f; calamityGlobalNPC.newAI[2] = 0f; @@ -5313,10 +5282,10 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Sound - if (npc.ai[2] == (float)(num11 - 60)) + if (npc.ai[2] == num11 - 60) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeRoar"), (int)npc.position.X, (int)npc.position.Y); - if (npc.ai[2] >= (float)(num11 - 60)) + if (npc.ai[2] >= num11 - 60) { if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % 18f == 0f) { @@ -5327,7 +5296,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num11) + if (npc.ai[2] >= num11) { calamityGlobalNPC.newAI[0] = 0f; calamityGlobalNPC.newAI[1] = 0f; @@ -5350,7 +5319,7 @@ namespace CalamityMod.NPCs // Teleport location if (npc.ai[1] == 0f) - npc.ai[1] = (float)(540 * Math.Sign((vector - player.Center).X)); + npc.ai[1] = 540 * Math.Sign((vector - player.Center).X); Vector2 desiredVelocity = Vector2.Normalize(player.Center + new Vector2(-npc.ai[1], -300f) - vector - npc.velocity) * scaleFactor; npc.SimpleFlyMovement(desiredVelocity, num3); @@ -5378,7 +5347,7 @@ namespace CalamityMod.NPCs if (calamityGlobalNPC.newAI[1] != 1f) { npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num2) + if (npc.ai[2] >= num2) { int num33 = 0; switch ((int)npc.ai[3]) @@ -5415,7 +5384,7 @@ namespace CalamityMod.NPCs // Velocity and rotation Vector2 distanceVector = player.Center + player.velocity * 20f - vector; npc.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction if (num32 != 0) @@ -5449,7 +5418,7 @@ namespace CalamityMod.NPCs { // Velocity and rotation npc.velocity = Vector2.Normalize(player.Center - vector) * scaleFactor4; - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction if (num32 != 0) @@ -5482,8 +5451,8 @@ namespace CalamityMod.NPCs int num34 = 7; 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) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); + Vector2 arg_2444_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((m - (num34 / 2 - 1)) * pie / num34) + vector; + Vector2 vector11 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * 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; @@ -5492,7 +5461,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)chargeTime) + if (npc.ai[2] >= chargeTime) { calamityGlobalNPC.newAI[0] += 30f; npc.ai[0] = 10f; @@ -5509,7 +5478,7 @@ namespace CalamityMod.NPCs npc.dontTakeDamage = true; // Alpha - if (npc.alpha < 255 && npc.ai[2] >= (float)num12 - 15f) + if (npc.alpha < 255 && npc.ai[2] >= num12 - 15f) { npc.alpha += 17; if (npc.alpha > 255) @@ -5521,14 +5490,14 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Play sound - if (npc.ai[2] == (float)(num12 / 2)) + if (npc.ai[2] == num12 / 2) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeRoar"), (int)npc.position.X, (int)npc.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == (float)(num12 / 2)) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == num12 / 2) { // Teleport location if (npc.ai[1] == 0f) - npc.ai[1] = (float)(480 * Math.Sign((vector - player.Center).X)); + npc.ai[1] = 480 * Math.Sign((vector - player.Center).X); // Rotation and direction Vector2 center = player.Center + new Vector2(npc.ai[1], -300f); @@ -5553,7 +5522,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num12) + if (npc.ai[2] >= num12) { npc.ai[0] = 10f; npc.ai[1] = 0f; @@ -5577,36 +5546,36 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Play sound - if (npc.ai[2] == (float)(num9 - 30)) + if (npc.ai[2] == num9 - 30) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeVomit"), (int)npc.position.X, (int)npc.position.Y); if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector7 = npc.rotation.ToRotationVector2() * (Vector2.UnitX * (float)npc.direction) * (float)(npc.width + 20) / 2f + vector; + Vector2 vector7 = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + vector; int damage = expertMode ? 55 : 70; for (int i = 0; i < 20; i++) { - float velocityX = (float)(npc.direction * 6) * (Main.rand.NextFloat() + 0.5f); + float velocityX = npc.direction * 6 * (Main.rand.NextFloat() + 0.5f); float velocityY = 8f * (Main.rand.NextFloat() + 0.5f); Projectile.NewProjectile(vector7.X, vector7.Y, velocityX, -velocityY, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); } } } - if (npc.ai[2] >= (float)(num9 - 90)) + if (npc.ai[2] >= num9 - 90) { if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % 18f == 0f) { calamityGlobalNPC.newAI[2] += 150f; float x = 900f - calamityGlobalNPC.newAI[2]; - NPC.NewNPC((int)(vector.X + x), (int)(vector.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, (float)npc.whoAmI, 0f, 255); - NPC.NewNPC((int)(vector.X - x), (int)(vector.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, (float)npc.whoAmI, 0f, 255); + NPC.NewNPC((int)(vector.X + x), (int)(vector.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + NPC.NewNPC((int)(vector.X - x), (int)(vector.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); } } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num9) + if (npc.ai[2] >= num9) { calamityGlobalNPC.newAI[0] += 30f; calamityGlobalNPC.newAI[2] = 0f; @@ -5626,14 +5595,14 @@ namespace CalamityMod.NPCs Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeRoar"), (int)npc.position.X, (int)npc.position.Y); int damage = expertMode ? 100 : 140; - Vector2 vortexSpawn = vector + npc.velocity.RotatedBy(MathHelper.PiOver2 * -(float)npc.direction) * spinTime / MathHelper.TwoPi; + Vector2 vortexSpawn = vector + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / MathHelper.TwoPi; if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(vortexSpawn.X, vortexSpawn.Y, 0f, 0f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); } } - if (npc.ai[2] % (float)num14 == 0f) + if (npc.ai[2] % num14 == 0f) { if (npc.ai[2] % 45f == 0f && npc.ai[2] != 0f) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeVomit"), (int)npc.position.X, (int)npc.position.Y); @@ -5643,18 +5612,18 @@ namespace CalamityMod.NPCs Vector2 vector10 = Vector2.Normalize(npc.velocity) * (float)(npc.width + 20) / 2f + vector; int num31 = NPC.NewNPC((int)vector10.X, (int)vector10.Y + 45, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); Main.npc[num31].target = npc.target; - Main.npc[num31].velocity = Vector2.Normalize(npc.velocity).RotatedBy((double)(1.57079637f * (float)npc.direction), default) * scaleFactor3; + Main.npc[num31].velocity = Vector2.Normalize(npc.velocity).RotatedBy(MathHelper.PiOver2 * npc.direction) * scaleFactor3; Main.npc[num31].netUpdate = true; - Main.npc[num31].ai[3] = (float)Main.rand.Next(30, 361); + Main.npc[num31].ai[3] = Main.rand.Next(30, 361); } } // Velocity and rotation - npc.velocity = npc.velocity.RotatedBy((double)(-(double)num15 * (float)npc.direction), default); - npc.rotation -= num15 * (float)npc.direction; + npc.velocity = npc.velocity.RotatedBy(-(double)num15 * (float)npc.direction); + npc.rotation -= num15 * npc.direction; npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num13) + if (npc.ai[2] >= num13) { calamityGlobalNPC.newAI[0] += 30f; npc.ai[0] = 10f; @@ -5675,9 +5644,6 @@ namespace CalamityMod.NPCs // Used for Brimling AI states CalamityGlobalNPC.brimstoneElemental = npc.whoAmI; - // Emit light - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 1.2f, 0f, 0f); - // Center Vector2 vectorCenter = npc.Center; @@ -5724,8 +5690,11 @@ namespace CalamityMod.NPCs // Reset defense npc.defense = npc.defDefense; + // Hide the sprite + npc.alpha = 255; + // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; // Variables for buffing the AI bool provy = CalamityWorld.downedProvidence && !CalamityWorld.bossRushActive; @@ -5735,20 +5704,6 @@ namespace CalamityMod.NPCs bool calamity = modPlayer.ZoneCalamity; bool phase2 = (lifeRatio < 0.5f && revenge) || death; - // Emit dust - int dustAmt = 1; - int size = 35; - for (int num1011 = 0; num1011 < 2; num1011++) - { - if (Main.rand.Next(3) < dustAmt) - { - int dust = Dust.NewDust(vectorCenter - new Vector2((float)size), size * 2, size * 2, 235, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 1.5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 0.2f; - Main.dust[dust].fadeIn = 1f; - } - } - // Speed while moving in phase 1 float speed = expertMode ? 5f : 4.5f; if (CalamityWorld.bossRushActive) @@ -5762,11 +5717,11 @@ namespace CalamityMod.NPCs float speedBoost = death ? 2f : 2f * (1f - lifeRatio); speed += speedBoost; - // Variables for target location relative to npc location + int damage = expertMode ? 125 : 200; float radialOffset = 32f; float xDistance = player.Center.X - vectorCenter.X; float yDistance = player.Center.Y - vectorCenter.Y; - float totalDistance = (float)Math.Sqrt((double)(xDistance * xDistance + yDistance * yDistance)); + float totalDistance = (float)Math.Sqrt(xDistance * xDistance + yDistance * yDistance); // Static movement towards target if (npc.ai[0] == 5f) @@ -5795,17 +5750,18 @@ namespace CalamityMod.NPCs npc.ai[1] += 1f; bool shootProjectile = false; - if (npc.ai[1] % 6f == 5f) + float fireRate = 60f; + if (npc.ai[1] % fireRate == fireRate - 1f) shootProjectile = true; if (shootProjectile) { if (Main.netMode != NetmodeID.MultiplayerClient) { - float num742 = 6f; - float num743 = player.position.X + (float)player.width * 0.5f - vectorCenter.X; - float num744 = player.position.Y + (float)player.height * 0.5f - vectorCenter.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num742 = 16f; + float num743 = player.position.X + player.width * 0.5f - vectorCenter.X; + float num744 = player.position.Y + player.height * 0.5f - vectorCenter.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; @@ -5814,24 +5770,30 @@ namespace CalamityMod.NPCs vectorCenter.X += num743 * 3f; vectorCenter.Y += num744 * 3f; - int damage = expertMode ? 25 : 30; + float radians = MathHelper.TwoPi / 3f; - Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, num743, num744, ModContent.ProjectileType(), damage + (provy ? 30 : 0), 0f, Main.myPlayer, 3f, 0f); - Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, num743, num744, ModContent.ProjectileType(), damage + (provy ? 30 : 0), 0f, Main.myPlayer, 4f, 0f); + for (int i = 0; i < 3; i++) + { + Vector2 vector = new Vector2(0f, -3f).RotatedBy(radians * i); + int proj = Projectile.NewProjectile(vectorCenter, vector, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 8f, 0f); + Main.projectile[proj].scale = 4f; + } + + //Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, num743, num744, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 4f, 0f); int numProj = 4; int spread = 45; float rotation = MathHelper.ToRadians(spread); float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); double startAngle = Math.Atan2(num743, num744) - rotation / 2; - double deltaAngle = rotation / (float)numProj; + double deltaAngle = rotation / numProj; double offsetAngle; - /*for (int i = 0; i < numProj; i++) + for (int i = 0; i < numProj; i++) { offsetAngle = startAngle + deltaAngle * i; - Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), ModContent.ProjectileType(), damage + (provy ? 30 : 0), 0f, Main.myPlayer, 5f, 0f); - }*/ + Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 10f, 0f); + } } } @@ -5840,7 +5802,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.98f; - npc.velocity.Y -= (CalamityWorld.bossRushActive ? 0.15f : 0.1f); + npc.velocity.Y -= CalamityWorld.bossRushActive ? 0.15f : 0.1f; if (npc.velocity.Y > 3f) npc.velocity.Y = 3f; @@ -5850,22 +5812,22 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.98f; - npc.velocity.Y += (CalamityWorld.bossRushActive ? 0.15f : 0.1f); + npc.velocity.Y += CalamityWorld.bossRushActive ? 0.15f : 0.1f; if (npc.velocity.Y < -3f) npc.velocity.Y = -3f; } - if (npc.position.X + (float)(npc.width / 2) > player.position.X + (float)(player.width / 2) + 150f) //100 + if (npc.position.X + (npc.width / 2) > player.position.X + (player.width / 2) + 150f) //100 { if (npc.velocity.X > 0f) npc.velocity.X *= 0.985f; - npc.velocity.X -= (CalamityWorld.bossRushActive ? 0.15f : 0.1f); + npc.velocity.X -= CalamityWorld.bossRushActive ? 0.15f : 0.1f; if (npc.velocity.X > 8f) npc.velocity.X = 8f; } - if (npc.position.X + (float)(npc.width / 2) < player.position.X + (float)(player.width / 2) - 150f) //100 + if (npc.position.X + (npc.width / 2) < player.position.X + (player.width / 2) - 150f) //100 { if (npc.velocity.X < 0f) npc.velocity.X *= 0.985f; @@ -5896,60 +5858,153 @@ namespace CalamityMod.NPCs { npc.localAI[0] += 1f; - if (npc.localAI[0] % 120f == 0f) - { - float projectileSpeed = revenge ? 8f : 6f; - if (CalamityWorld.bossRushActive) - projectileSpeed = 12f; + float projectileSpeed = revenge ? 8f : 6f; + if (CalamityWorld.bossRushActive) + projectileSpeed = 12f; - Vector2 targetVector = player.Center - vectorCenter; - targetVector.Y -= Math.Abs(targetVector.X) * 0.1f; + Vector2 targetVector = player.Center - vectorCenter; + float offsetAngle = 0f; + int totalProjectiles = 0; + int chains = 0; + + // Parabolic Arcs + if (npc.localAI[0] % 60f == 0f) + { + radialOffset = 0.1f; + float diameter = 90f; + + // Offset the arc so the central projectile(s) point towards the target + targetVector.Y -= Math.Abs(targetVector.X) * radialOffset; + + // Velocity of the arc moving towards the target targetVector = Vector2.Normalize(targetVector) * projectileSpeed; - npc.netUpdate = true; + // Offset the arc + Vector2 velocity = targetVector; + velocity.Normalize(); + velocity *= diameter; - int damage = expertMode ? 25 : 30; + totalProjectiles = 16; + int half = totalProjectiles / 2; + float scalar = 0.2f; + float velocityMult = (totalProjectiles - 1f) / 2f; + offsetAngle = (float)Math.PI * radialOffset; - // Can be used to create a large circle of projectiles fired at the target - float offsetAngle = (float)Math.PI * 0.1f; - int totalProjectiles = 10; + for (int j = 0; j < totalProjectiles; j++) + { + float radians = j - velocityMult; + Vector2 offset = velocity.RotatedBy(offsetAngle * radians, default); + int proj = Projectile.NewProjectile(vectorCenter + offset, targetVector * (1f - (Math.Abs(radians) / half * scalar)), ModContent.ProjectileType(), damage, 0f, Main.myPlayer, -1f, 0f); + } + } + + // Arcs + /*if (npc.localAI[0] % 60f == 0f) + { + radialOffset = 0.1f; + float diameter = 120f; + + targetVector.Y -= Math.Abs(targetVector.X) * radialOffset; + targetVector = Vector2.Normalize(targetVector) * projectileSpeed; Vector2 velocity = targetVector; velocity.Normalize(); - velocity *= 180f; + velocity *= diameter; - // Arcs - /*for (int j = 0; j < totalProjectiles; j++) - { - float num120 = (float)j - ((float)totalProjectiles - 1f) / 2f; - Vector2 offset = velocity.RotatedBy((double)(offsetAngle * num120), default); - int proj = Projectile.NewProjectile(vectorCenter + offset, targetVector, ModContent.ProjectileType(), damage + (provy ? 30 : 0), 0f, Main.myPlayer, -1f, 0f); - }*/ + totalProjectiles = 8; + offsetAngle = (float)Math.PI * radialOffset; - totalProjectiles = 18; - int offsetAngle2 = 360 / totalProjectiles; - for (int i = 0; i < totalProjectiles; i++) + for (int j = 0; j < totalProjectiles; j++) { - //Projectile.NewProjectile(vectorCenter, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, (float)(i * offsetAngle2)); - Projectile.NewProjectile(vectorCenter, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 12f, (float)(i * offsetAngle2)); + float radians = j - (totalProjectiles - 1f) / 2f; + Vector2 offset = velocity.RotatedBy(offsetAngle * radians, default); + int proj = Projectile.NewProjectile(vectorCenter + offset, targetVector, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, -1f, 0f); } } + + if (npc.localAI[0] % 120f == 0f) + { + totalProjectiles = 24; + offsetAngle = 360 / totalProjectiles; + for (int i = 0; i < totalProjectiles; i++) + { + Projectile.NewProjectile(vectorCenter, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 15f, i * offsetAngle); + } + + totalProjectiles = 16; + chains = 4; + float velocityTimer = 90f / (totalProjectiles / chains); + double radians = MathHelper.TwoPi / totalProjectiles; + int j = 0; + + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 vector = new Vector2(0f, -3f).RotatedBy(radians * i, default); + Projectile.NewProjectile(vectorCenter, vector, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 16f, j * velocityTimer); + + j++; + if (j % 4 == 0) + j = 0; + } + } + + totalProjectiles = 36; + float divisor = 6f; + chains = 3; + float interval = totalProjectiles / chains * divisor; + double patternInterval = Math.Floor(npc.localAI[0] / interval); + + if (patternInterval % 2 == 0) + { + if (npc.localAI[0] % divisor == 0f) + { + double radians = (patternInterval % 4 == 0 ? MathHelper.TwoPi + MathHelper.Pi / 3 : MathHelper.TwoPi) / chains; + radialOffset = MathHelper.ToRadians(npc.ai[2]); + + for (int i = 0; i < chains; i++) + { + Vector2 vector = new Vector2(0f, -3f).RotatedBy(radians * i + radialOffset, default); + Projectile.NewProjectile(vectorCenter, vector, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 3f, 0f); + } + + // Radial offset + npc.ai[2] += 5f; + } + } + else + npc.ai[2] = 0f;*/ + + /*if (npc.localAI[0] % 180f == 0f) + { + totalProjectiles = 12; + offsetAngle = 360 / totalProjectiles; + + for (int i = 0; i < totalProjectiles; i++) + { + Projectile.NewProjectile(vectorCenter, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, i * offsetAngle); + Projectile.NewProjectile(vectorCenter, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 12f, i * offsetAngle); + } + }*/ } - npc.velocity *= 0.95f; + if (npc.velocity.Length() > 0f) + npc.velocity = Vector2.Zero; + npc.rotation = npc.velocity.X * 0.04f; + float playerLocation = vectorCenter.X - player.Center.X; npc.direction = playerLocation < 0f ? 1 : -1; npc.spriteDirection = npc.direction; npc.ai[1] += 1f; - if (npc.ai[1] >= 300f) + if (npc.ai[1] >= 600f) { npc.TargetClosest(true); npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; + npc.localAI[0] = 0f; npc.netUpdate = true; } } @@ -6022,15 +6077,15 @@ namespace CalamityMod.NPCs int totalProjectiles = 4; float spread = MathHelper.ToRadians(90); // 30 degrees in radians = 0.523599 double startAngle = Math.Atan2(laserVelocity2.X, laserVelocity2.Y) - spread / 2; // Where the projectiles start spawning at, don't change this - double deltaAngle = spread / (float)totalProjectiles; // Angle between each projectile, 0.04363325 + double deltaAngle = spread / totalProjectiles; // Angle between each projectile, 0.04363325 double offsetAngle; int i; for (i = 0; i < 2; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + radialOffset * i; - Projectile.NewProjectile(source.X, source.Y, (float)(Math.Sin(offsetAngle)), (float)(Math.Cos(offsetAngle)), ModContent.ProjectileType(), 40, 0f, Main.myPlayer, 1f, (float)npc.whoAmI); - Projectile.NewProjectile(source.X, source.Y, (float)(-Math.Sin(offsetAngle)), (float)(-Math.Cos(offsetAngle)), ModContent.ProjectileType(), 40, 0f, Main.myPlayer, 1f, (float)npc.whoAmI); + Projectile.NewProjectile(source.X, source.Y, (float)Math.Sin(offsetAngle), (float)Math.Cos(offsetAngle), ModContent.ProjectileType(), 40, 0f, Main.myPlayer, 1f, npc.whoAmI); + Projectile.NewProjectile(source.X, source.Y, (float)-Math.Sin(offsetAngle), (float)-Math.Cos(offsetAngle), ModContent.ProjectileType(), 40, 0f, Main.myPlayer, 1f, npc.whoAmI); } } } @@ -6062,7 +6117,7 @@ namespace CalamityMod.NPCs { if (npc.ai[1] < 150f && calamityGlobalNPC.newAI[0] == 0f) { - Projectile.NewProjectile(source, laserVelocity, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, (float)npc.whoAmI); + Projectile.NewProjectile(source, laserVelocity, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI); calamityGlobalNPC.newAI[0] = 1f; } else @@ -6078,15 +6133,15 @@ namespace CalamityMod.NPCs int totalProjectiles = 4; float spread = MathHelper.ToRadians(90); // 30 degrees in radians = 0.523599 double startAngle = Math.Atan2(laserVelocity2.X, laserVelocity2.Y) - spread / 2; // Where the projectiles start spawning at, don't change this - double deltaAngle = spread / (float)totalProjectiles; // Angle between each projectile, 0.04363325 + double deltaAngle = spread / totalProjectiles; // Angle between each projectile, 0.04363325 double offsetAngle; int i; for (i = 0; i < 2; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + radialOffset * i; - Projectile.NewProjectile(source.X, source.Y, (float)(Math.Sin(offsetAngle)), (float)(Math.Cos(offsetAngle)), ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, (float)npc.whoAmI); - Projectile.NewProjectile(source.X, source.Y, (float)(-Math.Sin(offsetAngle)), (float)(-Math.Cos(offsetAngle)), ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, (float)npc.whoAmI); + Projectile.NewProjectile(source.X, source.Y, (float)Math.Sin(offsetAngle), (float)Math.Cos(offsetAngle), ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.whoAmI); + Projectile.NewProjectile(source.X, source.Y, (float)-Math.Sin(offsetAngle), (float)-Math.Cos(offsetAngle), ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.whoAmI); } } } diff --git a/NPCs/CalamityGlobalAI.cs b/NPCs/CalamityGlobalAI.cs index 1596da8475..6a3f5f39e2 100644 --- a/NPCs/CalamityGlobalAI.cs +++ b/NPCs/CalamityGlobalAI.cs @@ -51,8 +51,8 @@ namespace CalamityMod.NPCs } num2 *= num3; - Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num4 = (float)npc.direction * num / 2f; + Vector2 vector = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num4 = npc.direction * num / 2f; float num5 = -num / 2f; if (npc.velocity.X < num4) @@ -90,7 +90,7 @@ namespace CalamityMod.NPCs npc.rotation = npc.velocity.X * 0.1f; } else - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; float num11 = 0.7f; if (npc.collideX) @@ -108,9 +108,9 @@ namespace CalamityMod.NPCs npc.netUpdate = true; npc.velocity.Y = npc.oldVelocity.Y * -num11; - if (npc.velocity.Y > 0f && (double)npc.velocity.Y < 1.5) + if (npc.velocity.Y > 0f && npc.velocity.Y < 1.5) npc.velocity.Y = 2f; - if (npc.velocity.Y < 0f && (double)npc.velocity.Y > -1.5) + if (npc.velocity.Y < 0f && npc.velocity.Y > -1.5) npc.velocity.Y = -2f; } @@ -120,7 +120,7 @@ namespace CalamityMod.NPCs #endregion #region Buffed King Slime AI - public static bool BuffedKingSlimeAI(NPC npc, Mod mod) + public static bool BuffedKingSlimeAI(NPC npc, Mod mod, bool chaos) { // Variables float num234 = 1f; @@ -138,7 +138,7 @@ namespace CalamityMod.NPCs // Spawn crystal in phase 2 if (phase2 && !NPC.AnyNPCs(ModContent.NPCType())) { - Vector2 vector = npc.Center + new Vector2(-40f, (float)(-(float)npc.height / 2)); + Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2); for (int num621 = 0; num621 < 20; num621++) { int num622 = Dust.NewDust(vector, npc.width / 2, npc.height / 2, 90, 0f, 0f, 100, default, 2f); @@ -147,7 +147,7 @@ namespace CalamityMod.NPCs if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 38); @@ -156,7 +156,7 @@ namespace CalamityMod.NPCs // Set up health value for spawning slimes if (npc.ai[3] == 0f && npc.life > 0) - npc.ai[3] = (float)npc.lifeMax; + npc.ai[3] = npc.lifeMax; // Spawn with attack delay if (npc.localAI[3] == 0f && Main.netMode != NetmodeID.MultiplayerClient) @@ -223,7 +223,7 @@ namespace CalamityMod.NPCs int num241 = num240; int num242 = 0; - bool flag11 = Main.tile[num239, num241].nactive() && Main.tileSolid[(int)Main.tile[num239, num241].type] && !Main.tileSolidTop[(int)Main.tile[num239, num241].type]; + bool flag11 = Main.tile[num239, num241].nactive() && Main.tileSolid[Main.tile[num239, num241].type] && !Main.tileSolidTop[Main.tile[num239, num241].type]; if (flag11) { num242 = 1; @@ -233,7 +233,7 @@ namespace CalamityMod.NPCs while (num242 < 150 && num241 + num242 < Main.maxTilesY) { int num243 = num241 + num242; - bool flag12 = Main.tile[num239, num243].nactive() && Main.tileSolid[(int)Main.tile[num239, num243].type] && !Main.tileSolidTop[(int)Main.tile[num239, num243].type]; + bool flag12 = Main.tile[num239, num243].nactive() && Main.tileSolid[Main.tile[num239, num243].type] && !Main.tileSolidTop[Main.tile[num239, num243].type]; if (flag12) { num242--; @@ -253,8 +253,8 @@ namespace CalamityMod.NPCs if (flag13) { - npc.localAI[1] = (float)(num239 * 16 + 8); - npc.localAI[2] = (float)(num240 * 16 + 16); + npc.localAI[1] = num239 * 16 + 8; + npc.localAI[2] = num240 * 16 + 16; break; } } @@ -262,7 +262,7 @@ namespace CalamityMod.NPCs if (num238 >= 100) { - Vector2 bottom = Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].Bottom; + Vector2 bottom = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Bottom; npc.localAI[1] = bottom.X; npc.localAI[2] = bottom.Y; } @@ -291,7 +291,7 @@ namespace CalamityMod.NPCs flag9 = true; if (npc.ai[0] == 60f) - Gore.NewGore(npc.Center + new Vector2(-40f, (float)(-(float)npc.height / 2)), npc.velocity, 734, 1f); + Gore.NewGore(npc.Center + new Vector2(-40f, -(float)npc.height / 2), npc.velocity, 734, 1f); if (npc.ai[0] >= 60f && Main.netMode != NetmodeID.MultiplayerClient) { @@ -363,7 +363,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y == 0f) { npc.velocity.X *= 0.8f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; if (!flag8) @@ -373,16 +373,16 @@ namespace CalamityMod.NPCs npc.ai[0] += 9f; else { - if ((double)npc.life < (double)npc.lifeMax * 0.8 || death) + if (npc.life < npc.lifeMax * 0.8 || death) npc.ai[0] += 1f; - if ((double)npc.life < (double)npc.lifeMax * 0.6 || death) + if (npc.life < npc.lifeMax * 0.6 || death) npc.ai[0] += 1f; - if ((double)npc.life < (double)npc.lifeMax * 0.4 || death) + if (npc.life < npc.lifeMax * 0.4 || death) npc.ai[0] += 2f; } - if ((double)npc.life < (double)npc.lifeMax * 0.2 || death) + if (npc.life < npc.lifeMax * 0.2 || death) npc.ai[0] += 3f; - if ((double)npc.life < (double)npc.lifeMax * 0.1 || death) + if (npc.life < npc.lifeMax * 0.1 || death) npc.ai[0] += 4f; if (npc.ai[0] >= 0f) @@ -402,7 +402,7 @@ namespace CalamityMod.NPCs if (npc.ai[1] == 3f) { npc.velocity.Y = -13f * speedMult; - npc.velocity.X += (phase2 ? 4f : 3.5f) * (float)npc.direction; + npc.velocity.X += (phase2 ? 4f : 3.5f) * npc.direction; if (CalamityWorld.bossRushActive) npc.velocity.X *= 2f; @@ -412,7 +412,7 @@ namespace CalamityMod.NPCs else if (npc.ai[1] == 2f) { npc.velocity.Y = -6f * speedMult; - npc.velocity.X += (phase2 ? 5f : 4.5f) * (float)npc.direction; + npc.velocity.X += (phase2 ? 5f : 4.5f) * npc.direction; if (CalamityWorld.bossRushActive) npc.velocity.X *= 2f; @@ -422,7 +422,7 @@ namespace CalamityMod.NPCs else { npc.velocity.Y = -8f * speedMult; - npc.velocity.X += (phase2 ? 4.5f : 4f) * (float)npc.direction; + npc.velocity.X += (phase2 ? 4.5f : 4f) * npc.direction; if (CalamityWorld.bossRushActive) npc.velocity.X *= 2f; @@ -438,8 +438,8 @@ namespace CalamityMod.NPCs // Change jump velocity else if (npc.target < Main.maxPlayers && ((npc.direction == 1 && npc.velocity.X < 3f) || (npc.direction == -1 && npc.velocity.X > -3f))) { - if ((npc.direction == -1 && (double)npc.velocity.X < 0.1) || (npc.direction == 1 && (double)npc.velocity.X > -0.1)) - npc.velocity.X += (CalamityWorld.bossRushActive ? 0.4f : 0.2f) * (float)npc.direction; + if ((npc.direction == -1 && npc.velocity.X < 0.1) || (npc.direction == 1 && npc.velocity.X > -0.1)) + npc.velocity.X += (CalamityWorld.bossRushActive ? 0.4f : 0.2f) * npc.direction; else npc.velocity.X *= CalamityWorld.bossRushActive ? 0.9f : 0.93f; } @@ -457,28 +457,28 @@ namespace CalamityMod.NPCs lifeRatio *= num234; if (lifeRatio != npc.scale) { - npc.position.X += (float)(npc.width / 2); - npc.position.Y += (float)npc.height; + npc.position.X += npc.width / 2; + npc.position.Y += npc.height; npc.scale = lifeRatio; npc.width = (int)(98f * npc.scale); npc.height = (int)(92f * npc.scale); - npc.position.X -= (float)(npc.width / 2); - npc.position.Y -= (float)npc.height; + npc.position.X -= npc.width / 2; + npc.position.Y -= npc.height; } // Slime spawning if (Main.netMode != NetmodeID.MultiplayerClient) { - int num251 = (int)((double)npc.lifeMax * 0.05); - if ((float)(npc.life + num251) < npc.ai[3]) + int num251 = (int)(npc.lifeMax * 0.05); + if (npc.life + num251 < npc.ai[3]) { - npc.ai[3] = (float)npc.life; + npc.ai[3] = npc.life; int num252 = Main.rand.Next(2, 4); int num; for (int num253 = 0; num253 < num252; num253 = num + 1) { - int x = (int)(npc.position.X + (float)Main.rand.Next(npc.width - 32)); - int y = (int)(npc.position.Y + (float)Main.rand.Next(npc.height - 32)); + int x = (int)(npc.position.X + Main.rand.Next(npc.width - 32)); + int y = (int)(npc.position.Y + Main.rand.Next(npc.height - 32)); int random = phase2 ? 10 : 8; int npcType = Main.rand.Next(random); @@ -525,9 +525,9 @@ namespace CalamityMod.NPCs int num255 = NPC.NewNPC(x, y, npcType, 0, 0f, 0f, 0f, 0f, 255); Main.npc[num255].SetDefaults(npcType, -1f); - Main.npc[num255].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num255].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num255].ai[0] = (float)(-1000 * Main.rand.Next(3)); + Main.npc[num255].velocity.X = Main.rand.Next(-15, 16) * 0.1f; + Main.npc[num255].velocity.Y = Main.rand.Next(-30, 1) * 0.1f; + Main.npc[num255].ai[0] = -1000 * Main.rand.Next(3); Main.npc[num255].ai[1] = 0f; if (Main.netMode == NetmodeID.Server && num255 < Main.maxNPCs) @@ -547,14 +547,14 @@ namespace CalamityMod.NPCs #endregion #region Buffed Eye of Cthulhu AI - public static bool BuffedEyeofCthulhuAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedEyeofCthulhuAI(NPC npc, bool enraged, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); bool configBossRushBoost = CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive; float num5 = 20f; // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; bool death = CalamityWorld.death || CalamityWorld.bossRushActive; bool phase2 = lifeRatio < 0.85f || death; bool phase3 = lifeRatio < 0.75f || death; @@ -565,14 +565,14 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); bool dead = Main.player[npc.target].dead; - float num6 = npc.position.X + (float)(npc.width / 2) - Main.player[npc.target].position.X - (float)(Main.player[npc.target].width / 2); - float num7 = npc.position.Y + (float)npc.height - 59f - Main.player[npc.target].position.Y - (float)(Main.player[npc.target].height / 2); - float num8 = (float)Math.Atan2((double)num7, (double)num6) + 1.57f; + float num6 = npc.position.X + (npc.width / 2) - Main.player[npc.target].position.X - (Main.player[npc.target].width / 2); + float num7 = npc.position.Y + npc.height - 59f - Main.player[npc.target].position.Y - (Main.player[npc.target].height / 2); + float num8 = (float)Math.Atan2(num7, num6) + MathHelper.PiOver2; if (num8 < 0f) - num8 += 6.283f; - else if ((double)num8 > 6.283) - num8 -= 6.283f; + num8 += MathHelper.TwoPi; + else if (num8 > MathHelper.TwoPi) + num8 -= MathHelper.TwoPi; float num9 = 0f; if (npc.ai[0] == 0f && npc.ai[1] == 0f) @@ -591,14 +591,14 @@ namespace CalamityMod.NPCs if (npc.rotation < num8) { - if ((double)(num8 - npc.rotation) > 3.1415) + if ((num8 - npc.rotation) > MathHelper.Pi) npc.rotation -= num9; else npc.rotation += num9; } else if (npc.rotation > num8) { - if ((double)(npc.rotation - num8) > 3.1415) + if ((npc.rotation - num8) > MathHelper.Pi) npc.rotation += num9; else npc.rotation -= num9; @@ -607,15 +607,15 @@ namespace CalamityMod.NPCs if (npc.rotation > num8 - num9 && npc.rotation < num8 + num9) npc.rotation = num8; if (npc.rotation < 0f) - npc.rotation += 6.283f; - else if ((double)npc.rotation > 6.283) - npc.rotation -= 6.283f; + npc.rotation += MathHelper.TwoPi; + else if (npc.rotation > MathHelper.TwoPi) + npc.rotation -= MathHelper.TwoPi; if (npc.rotation > num8 - num9 && npc.rotation < num8 + num9) npc.rotation = num8; if (Main.rand.NextBool(5)) { - int num10 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default, 1f); + int num10 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default, 1f); Dust dust = Main.dust[num10]; dust.velocity.X *= 0.5f; dust.velocity.Y *= 0.1f; @@ -636,10 +636,10 @@ namespace CalamityMod.NPCs float num11 = 7f; float num12 = 0.15f; - Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num13 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector.X; - float num14 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 200f - vector.Y; - float num15 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14)); + Vector2 vector = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num13 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector.X; + float num14 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 200f - vector.Y; + float num15 = (float)Math.Sqrt(num13 * num13 + num14 * num14); float num16 = num15; num15 = num11 / num15; @@ -692,9 +692,9 @@ namespace CalamityMod.NPCs npc.rotation = num8; float num19 = 6f; - float num20 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector.X; - float num21 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + float num20 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector.X; + float num21 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector.Y; + float num22 = (float)Math.Sqrt(num20 * num20 + num21 * num21); num22 = num19 / num22; Vector2 vector2 = vector; @@ -730,10 +730,10 @@ namespace CalamityMod.NPCs npc.rotation = num8; float num24 = 7.25f; - Vector2 vector4 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num25 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector4.X; - float num26 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector4.Y; - float num27 = (float)Math.Sqrt((double)(num25 * num25 + num26 * num26)); + Vector2 vector4 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num25 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector4.X; + float num26 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector4.Y; + float num27 = (float)Math.Sqrt(num25 * num25 + num26 * num26); num27 = num24 / num27; npc.velocity.X = num25 * num27; @@ -751,16 +751,16 @@ namespace CalamityMod.NPCs if (npc.ai[2] >= 40f) { npc.velocity *= 0.975f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) npc.velocity.Y = 0f; } else - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; int num28 = 90; - if (npc.ai[2] >= (float)num28) + if (npc.ai[2] >= num28) { npc.ai[3] += 1f; npc.ai[2] = 0f; @@ -795,7 +795,7 @@ namespace CalamityMod.NPCs if (npc.ai[0] == 1f) { npc.ai[2] += 0.005f; - if ((double)npc.ai[2] > 0.5) + if (npc.ai[2] > 0.5) npc.ai[2] = 0.5f; } else @@ -809,10 +809,10 @@ namespace CalamityMod.NPCs npc.ai[1] += 1f; if (npc.ai[1] % 20f == 0f) { - Vector2 vector5 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num31 = (float)Main.rand.Next(-200, 200); - float num32 = (float)Main.rand.Next(-200, 200); - float num33 = (float)Math.Sqrt((double)(num31 * num31 + num32 * num32)); + Vector2 vector5 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num31 = Main.rand.Next(-200, 200); + float num32 = Main.rand.Next(-200, 200); + float num33 = (float)Math.Sqrt(num31 * num31 + num32 * num32); num33 = 8f / num33; Vector2 vector6 = vector5; @@ -854,34 +854,34 @@ namespace CalamityMod.NPCs int num; for (int num35 = 0; num35 < 2; num35 = num + 1) { - Gore.NewGore(npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 8, 1f); - Gore.NewGore(npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 7, 1f); - Gore.NewGore(npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 6, 1f); + Gore.NewGore(npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 8, 1f); + Gore.NewGore(npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 7, 1f); + Gore.NewGore(npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 6, 1f); num = num35; } for (int num36 = 0; num36 < 20; num36 = num + 1) { - Dust.NewDust(npc.position, npc.width, npc.height, 5, (float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); + Dust.NewDust(npc.position, npc.width, npc.height, 5, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); num = num36; } Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0, 1f, 0f); } } - Dust.NewDust(npc.position, npc.width, npc.height, 5, (float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); + Dust.NewDust(npc.position, npc.width, npc.height, 5, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); npc.velocity *= 0.98f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) npc.velocity.Y = 0f; } else { npc.defense = 6; - npc.damage = (int)((float)npc.defDamage * (phase5 ? 1.4f : 1.2f)); + npc.damage = (int)(npc.defDamage * (phase5 ? 1.4f : 1.2f)); if (npc.ai[1] == 0f & phase5) npc.ai[1] = 5f; @@ -896,10 +896,10 @@ namespace CalamityMod.NPCs num38 *= 2f; } - Vector2 vector8 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num39 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector8.X; - float num40 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 120f - vector8.Y; - float num41 = (float)Math.Sqrt((double)(num39 * num39 + num40 * num40)); + Vector2 vector8 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num39 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector8.X; + float num40 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 120f - vector8.Y; + float num41 = (float)Math.Sqrt(num39 * num39 + num40 * num40); if (num41 > 400f) { @@ -974,10 +974,10 @@ namespace CalamityMod.NPCs if (CalamityWorld.bossRushActive) num42 *= 2f; - Vector2 vector9 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num43 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector9.X; - float num44 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector9.Y; - float num45 = (float)Math.Sqrt((double)(num43 * num43 + num44 * num44)); + Vector2 vector9 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num43 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector9.X; + float num44 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector9.Y; + float num45 = (float)Math.Sqrt(num43 * num43 + num44 * num44); num45 = num42 / num45; npc.velocity.X = num43 * num45; @@ -997,16 +997,16 @@ namespace CalamityMod.NPCs if (npc.ai[2] >= num46) { npc.velocity *= 0.96f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) npc.velocity.Y = 0f; } else - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; int num47 = 80; - if (npc.ai[2] >= (float)num47) + if (npc.ai[2] >= num47) { npc.ai[3] += 1f; npc.ai[2] = 0f; @@ -1020,7 +1020,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient && phase3) { npc.ai[1] = 3f; - npc.ai[3] += (float)Main.rand.Next(1, 4); + npc.ai[3] += Main.rand.Next(1, 4); } npc.netUpdate = true; @@ -1053,9 +1053,9 @@ namespace CalamityMod.NPCs if (CalamityWorld.bossRushActive) num48 *= 1.5f; - Vector2 vector10 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num49 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector10.X; - float num50 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector10.Y; + Vector2 vector10 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num49 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector10.X; + float num50 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector10.Y; float num51 = Math.Abs(Main.player[npc.target].velocity.X) + Math.Abs(Main.player[npc.target].velocity.Y) / 4f; num51 += 10f - num51; @@ -1072,17 +1072,17 @@ namespace CalamityMod.NPCs num49 -= Main.player[npc.target].velocity.X * num51; num50 -= Main.player[npc.target].velocity.Y * num51 / 4f; - num49 *= 1f + (float)Main.rand.Next(-10, 11) * 0.01f; - num50 *= 1f + (float)Main.rand.Next(-10, 11) * 0.01f; + num49 *= 1f + Main.rand.Next(-10, 11) * 0.01f; + num50 *= 1f + Main.rand.Next(-10, 11) * 0.01f; - float num52 = (float)Math.Sqrt((double)(num49 * num49 + num50 * num50)); + float num52 = (float)Math.Sqrt(num49 * num49 + num50 * num50); float num53 = num52; num52 = num48 / num52; npc.velocity.X = num49 * num52; npc.velocity.Y = num50 * num52; - npc.velocity.X += (float)Main.rand.Next(-20, 21) * 0.1f; - npc.velocity.Y += (float)Main.rand.Next(-20, 21) * 0.1f; + npc.velocity.X += Main.rand.Next(-20, 21) * 0.1f; + npc.velocity.Y += Main.rand.Next(-20, 21) * 0.1f; if (num53 < 100f) { @@ -1135,13 +1135,13 @@ namespace CalamityMod.NPCs if (npc.ai[2] >= num60) { npc.velocity *= 0.95f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) npc.velocity.Y = 0f; } else - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; float num61 = num60 + 13f; if (npc.ai[2] >= num61) @@ -1177,9 +1177,9 @@ namespace CalamityMod.NPCs num64 *= 2f; } - Vector2 vector11 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num65 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector11.X; - float num66 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) + num62 - vector11.Y; + Vector2 vector11 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num65 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector11.X; + float num66 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) + num62 - vector11.Y; bool horizontalCharge = calamityGlobalNPC.newAI[0] == 1f || calamityGlobalNPC.newAI[0] == 3f; if (horizontalCharge) @@ -1188,11 +1188,11 @@ namespace CalamityMod.NPCs num63 *= 1.5f; num64 *= 1.5f; - num65 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) + num62 - vector11.X; - num66 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector11.Y; + num65 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + num62 - vector11.X; + num66 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector11.Y; } - float num67 = (float)Math.Sqrt((double)(num65 * num65 + num66 * num66)); + float num67 = (float)Math.Sqrt(num65 * num65 + num66 * num66); num67 = num63 / num67; num65 *= num67; num66 *= num67; @@ -1227,10 +1227,10 @@ namespace CalamityMod.NPCs if (npc.ai[2] % 45f == 0f) { float num19 = CalamityWorld.bossRushActive ? 9f : 6f; - Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num20 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector.X; - float num21 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + Vector2 vector = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num20 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector.X; + float num21 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector.Y; + float num22 = (float)Math.Sqrt(num20 * num20 + num21 * num21); num22 = num19 / num22; Vector2 vector2 = vector; @@ -1306,10 +1306,10 @@ namespace CalamityMod.NPCs if (CalamityWorld.bossRushActive) num48 *= 1.5f; - Vector2 vector10 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num49 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector10.X; - float num50 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector10.Y; - float num51 = (float)Math.Sqrt((double)(num49 * num49 + num50 * num50)); + Vector2 vector10 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num49 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector10.X; + float num50 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector10.Y; + float num51 = (float)Math.Sqrt(num49 * num49 + num50 * num50); num51 = num48 / num51; npc.velocity.X = num49 * num51; @@ -1337,13 +1337,13 @@ namespace CalamityMod.NPCs if (npc.ai[2] >= num60) { npc.velocity *= 0.95f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) npc.velocity.Y = 0f; } else - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; float num61 = num60 + 13f; if (npc.ai[2] >= num61) @@ -1367,7 +1367,7 @@ namespace CalamityMod.NPCs #endregion #region Buffed Eater of Worlds AI - public static bool BuffedEaterofWorldsAI(NPC npc, Mod mod) + public static bool BuffedEaterofWorldsAI(NPC npc, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); bool configBossRushBoost = CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive; @@ -1377,7 +1377,7 @@ namespace CalamityMod.NPCs float totalSegments = death ? 73f : 63f; // Count segments remaining - float segmentCount = (float)(NPC.CountNPCS(NPCID.EaterofWorldsHead) + NPC.CountNPCS(NPCID.EaterofWorldsBody) + NPC.CountNPCS(NPCID.EaterofWorldsTail)); // 2f to 65f + float segmentCount = NPC.CountNPCS(NPCID.EaterofWorldsHead) + NPC.CountNPCS(NPCID.EaterofWorldsBody) + NPC.CountNPCS(NPCID.EaterofWorldsTail); // 2f to 65f // Percent segments remaining, add two to total for head and tail float lifeRatio = segmentCount / (totalSegments + 2); @@ -1390,7 +1390,7 @@ namespace CalamityMod.NPCs // Damage if (phase4 && npc.type == NPCID.EaterofWorldsHead) - npc.damage = (int)((float)npc.defDamage * (phase5 ? 1.2f : 1.1f)); + npc.damage = (int)(npc.defDamage * (phase5 ? 1.2f : 1.1f)); // Fire projectiles if (Main.netMode != NetmodeID.MultiplayerClient && !phase5) @@ -1402,7 +1402,7 @@ namespace CalamityMod.NPCs { npc.TargetClosest(true); if (Collision.CanHitLine(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2) + npc.velocity.X), (int)(npc.position.Y + (float)(npc.height / 2) + npc.velocity.Y), NPCID.VileSpit, 0, 0f, 1f, 0f, 0f, 255); + NPC.NewNPC((int)(npc.position.X + (npc.width / 2) + npc.velocity.X), (int)(npc.position.Y + (npc.height / 2) + npc.velocity.Y), NPCID.VileSpit, 0, 0f, 1f, 0f, 0f, 255); } } @@ -1422,10 +1422,10 @@ namespace CalamityMod.NPCs if (Collision.CanHitLine(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) { - Vector2 vector34 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num349 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector34.X; - float num350 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector34.Y; - float num351 = (float)Math.Sqrt((double)(num349 * num349 + num350 * num350)); + Vector2 vector34 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num349 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector34.X; + float num350 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector34.Y; + float num351 = (float)Math.Sqrt(num349 * num349 + num350 * num350); num349 *= num351; num350 *= num351; @@ -1435,7 +1435,7 @@ namespace CalamityMod.NPCs if (death) num419 += 2; int num420 = ProjectileID.CursedFlameHostile; - num351 = (float)Math.Sqrt((double)(num349 * num349 + num350 * num350)); + num351 = (float)Math.Sqrt(num349 * num349 + num350 * num350); num351 = num418 / num351; num349 *= num351; num350 *= num351; @@ -1474,21 +1474,21 @@ namespace CalamityMod.NPCs npc.ai[2] = totalSegments; // Body spawn - npc.ai[0] = (float)NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), npc.type + 1, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + npc.ai[0] = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)(npc.position.Y + npc.height), npc.type + 1, npc.whoAmI, 0f, 0f, 0f, 0f, 255); } else if (npc.type == NPCID.EaterofWorldsBody && npc.ai[2] > 0f) { // Body spawn - npc.ai[0] = (float)NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), npc.type, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + npc.ai[0] = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)(npc.position.Y + npc.height), npc.type, npc.whoAmI, 0f, 0f, 0f, 0f, 255); } else { // Tail spawn - npc.ai[0] = (float)NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), npc.type + 1, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + npc.ai[0] = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)(npc.position.Y + npc.height), npc.type + 1, npc.whoAmI, 0f, 0f, 0f, 0f, 255); } // Worm shit - Main.npc[(int)npc.ai[0]].ai[1] = (float)npc.whoAmI; + Main.npc[(int)npc.ai[0]].ai[1] = npc.whoAmI; Main.npc[(int)npc.ai[0]].ai[2] = npc.ai[2] - 1f; npc.netUpdate = true; } @@ -1522,27 +1522,31 @@ namespace CalamityMod.NPCs { npc.type = NPCID.EaterofWorldsHead; int whoAmI = npc.whoAmI; - float num25 = (float)npc.life / (float)npc.lifeMax; + float num25 = npc.life / (float)npc.lifeMax; float num26 = npc.ai[0]; + int aiTimer = calamityGlobalNPC.AITimer; npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)((float)npc.lifeMax * num25); + npc.life = (int)(npc.lifeMax * num25); npc.ai[0] = num26; npc.TargetClosest(true); npc.netUpdate = true; npc.whoAmI = whoAmI; + calamityGlobalNPC.AITimer = aiTimer; } if (npc.type == NPCID.EaterofWorldsBody && (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].aiStyle != npc.aiStyle)) { int whoAmI2 = npc.whoAmI; - float num27 = (float)npc.life / (float)npc.lifeMax; + float num27 = npc.life / (float)npc.lifeMax; float num28 = npc.ai[1]; - npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)((float)npc.lifeMax * num27); + int aiTimer = calamityGlobalNPC.AITimer; + npc.SetDefaultsKeepPlayerInteraction(npc.type); + npc.life = (int)(npc.lifeMax * num27); npc.ai[1] = num28; npc.TargetClosest(true); npc.netUpdate = true; npc.whoAmI = whoAmI2; - } + calamityGlobalNPC.AITimer = aiTimer; + } if (!npc.active && Main.netMode == NetmodeID.Server) NetMessage.SendData(28, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); @@ -1550,9 +1554,9 @@ namespace CalamityMod.NPCs // Movement int num29 = (int)(npc.position.X / 16f) - 1; - int num30 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; + int num30 = (int)((npc.position.X + npc.width) / 16f) + 2; int num31 = (int)(npc.position.Y / 16f) - 1; - int num32 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; + int num32 = (int)((npc.position.Y + npc.height) / 16f) + 2; if (num29 < 0) num29 = 0; if (num30 > Main.maxTilesX) @@ -1570,12 +1574,12 @@ namespace CalamityMod.NPCs { for (int num34 = num31; num34 < num32; num34++) { - if (Main.tile[num33, num34] != null && ((Main.tile[num33, num34].nactive() && (Main.tileSolid[(int)Main.tile[num33, num34].type] || (Main.tileSolidTop[(int)Main.tile[num33, num34].type] && Main.tile[num33, num34].frameY == 0))) || Main.tile[num33, num34].liquid > 64)) + if (Main.tile[num33, num34] != null && ((Main.tile[num33, num34].nactive() && (Main.tileSolid[Main.tile[num33, num34].type] || (Main.tileSolidTop[Main.tile[num33, num34].type] && Main.tile[num33, num34].frameY == 0))) || Main.tile[num33, num34].liquid > 64)) { Vector2 vector; - vector.X = (float)(num33 * 16); - vector.Y = (float)(num34 * 16); - if (npc.position.X + (float)npc.width > vector.X && npc.position.X < vector.X + 16f && npc.position.Y + (float)npc.height > vector.Y && npc.position.Y < vector.Y + 16f) + vector.X = num33 * 16; + vector.Y = num34 * 16; + if (npc.position.X + npc.width > vector.X && npc.position.X < vector.X + 16f && npc.position.Y + npc.height > vector.Y && npc.position.Y < vector.Y + 16f) { flag2 = true; if (Main.rand.NextBool(100) && Main.tile[num33, num34].nactive()) @@ -1628,34 +1632,34 @@ namespace CalamityMod.NPCs num38 += 0.015f; } - Vector2 vector2 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num39 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num40 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); + Vector2 vector2 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num39 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float num40 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); - num39 = (float)((int)(num39 / 16f) * 16); - num40 = (float)((int)(num40 / 16f) * 16); - vector2.X = (float)((int)(vector2.X / 16f) * 16); - vector2.Y = (float)((int)(vector2.Y / 16f) * 16); + num39 = (int)(num39 / 16f) * 16; + num40 = (int)(num40 / 16f) * 16; + vector2.X = (int)(vector2.X / 16f) * 16; + vector2.Y = (int)(vector2.Y / 16f) * 16; num39 -= vector2.X; num40 -= vector2.Y; - float num52 = (float)Math.Sqrt((double)(num39 * num39 + num40 * num40)); + float num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector2 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num39 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector2.X; - num40 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector2.Y; + vector2 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num39 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector2.X; + num40 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector2.Y; } catch { } - npc.rotation = (float)Math.Atan2((double)num40, (double)num39) + 1.57f; - num52 = (float)Math.Sqrt((double)(num39 * num39 + num40 * num40)); + npc.rotation = (float)Math.Atan2(num40, num39) + MathHelper.PiOver2; + num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); int num53 = npc.width; - num53 = (int)((float)num53 * npc.scale); - num52 = (num52 - (float)num53) / num52; + num53 = (int)(num53 * npc.scale); + num52 = (num52 - num53) / num52; num39 *= num52; num40 *= num52; npc.velocity = Vector2.Zero; @@ -1681,7 +1685,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y > num37) npc.velocity.Y = num37; - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num37 * 0.4) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num37 * 0.4) { if (npc.velocity.X < 0f) npc.velocity.X -= num38 * 1.1f; @@ -1718,7 +1722,7 @@ namespace CalamityMod.NPCs Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f); } - num52 = (float)Math.Sqrt((double)(num39 * num39 + num40 * num40)); + num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); float num55 = Math.Abs(num39); float num56 = Math.Abs(num40); float num57 = num37 / num52; @@ -1738,7 +1742,7 @@ namespace CalamityMod.NPCs if (flag5) { - if (Main.netMode != NetmodeID.MultiplayerClient && (double)(npc.position.Y / 16f) > (Main.rockLayer + (double)Main.maxTilesY) / 2.0) + if (Main.netMode != NetmodeID.MultiplayerClient && (npc.position.Y / 16f) > (Main.rockLayer + Main.maxTilesY) / 2.0) { npc.active = false; int num59 = (int)npc.ai[0]; @@ -1774,7 +1778,7 @@ namespace CalamityMod.NPCs else if (npc.velocity.Y > num40) npc.velocity.Y -= num38; - if ((double)Math.Abs(num40) < (double)num37 * 0.2 && ((npc.velocity.X > 0f && num39 < 0f) || (npc.velocity.X < 0f && num39 > 0f))) + if (Math.Abs(num40) < num37 * 0.2 && ((npc.velocity.X > 0f && num39 < 0f) || (npc.velocity.X < 0f && num39 > 0f))) { if (npc.velocity.Y > 0f) npc.velocity.Y += num38 * 2f; @@ -1782,7 +1786,7 @@ namespace CalamityMod.NPCs npc.velocity.Y -= num38 * 2f; } - if ((double)Math.Abs(num39) < (double)num37 * 0.2 && ((npc.velocity.Y > 0f && num40 < 0f) || (npc.velocity.Y < 0f && num40 > 0f))) + if (Math.Abs(num39) < num37 * 0.2 && ((npc.velocity.Y > 0f && num40 < 0f) || (npc.velocity.Y < 0f && num40 > 0f))) { if (npc.velocity.X > 0f) npc.velocity.X += num38 * 2f; @@ -1797,7 +1801,7 @@ namespace CalamityMod.NPCs else if (npc.velocity.X > num39) npc.velocity.X -= num38 * 1.1f; - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num37 * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num37 * 0.5) { if (npc.velocity.Y > 0f) npc.velocity.Y += num38; @@ -1812,7 +1816,7 @@ namespace CalamityMod.NPCs else if (npc.velocity.Y > num40) npc.velocity.Y -= num38 * 1.1f; - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num37 * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num37 * 0.5) { if (npc.velocity.X > 0f) npc.velocity.X += num38; @@ -1822,7 +1826,7 @@ namespace CalamityMod.NPCs } } - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; if (npc.type == NPCID.EaterofWorldsHead) { @@ -1853,7 +1857,7 @@ namespace CalamityMod.NPCs #endregion #region Buffed Brain of Cthulhu AI - public static bool BuffedBrainofCthulhuAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedBrainofCthulhuAI(NPC npc, bool enraged, Mod mod, bool chaos) { // whoAmI variable NPC.crimsonBoss = npc.whoAmI; @@ -1866,11 +1870,11 @@ namespace CalamityMod.NPCs { float num790 = npc.Center.X; float num791 = npc.Center.Y; - num790 += (float)Main.rand.Next(-npc.width, npc.width); - num791 += (float)Main.rand.Next(-npc.height, npc.height); + num790 += Main.rand.Next(-npc.width, npc.width); + num791 += Main.rand.Next(-npc.height, npc.height); int num792 = NPC.NewNPC((int)num790, (int)num791, NPCID.Creeper, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num792].velocity = new Vector2((float)Main.rand.Next(-30, 31) * 0.1f, (float)Main.rand.Next(-30, 31) * 0.1f); + Main.npc[num792].velocity = new Vector2(Main.rand.Next(-30, 31) * 0.1f, Main.rand.Next(-30, 31) * 0.1f); Main.npc[num792].netUpdate = true; } } @@ -1900,19 +1904,19 @@ namespace CalamityMod.NPCs npc.localAI[2] = 1f; - Gore.NewGore(npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 392, 1f); - Gore.NewGore(npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 393, 1f); - Gore.NewGore(npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 394, 1f); - Gore.NewGore(npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 395, 1f); + Gore.NewGore(npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 392, 1f); + Gore.NewGore(npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 393, 1f); + Gore.NewGore(npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 394, 1f); + Gore.NewGore(npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 395, 1f); for (int num794 = 0; num794 < 20; num794++) - Dust.NewDust(npc.position, npc.width, npc.height, 5, (float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); + Dust.NewDust(npc.position, npc.width, npc.height, 5, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0, 1f, 0f); } // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; // Phases based on HP bool death = CalamityWorld.death || CalamityWorld.bossRushActive; @@ -1929,7 +1933,7 @@ namespace CalamityMod.NPCs npc.dontTakeDamage = false; // Deal no damage while spinning - npc.damage = spinning ? 0 : (int)((float)npc.defDamage * (phase5 ? 1.2f : 1f)); + npc.damage = spinning ? 0 : (int)(npc.defDamage * (phase5 ? 1.2f : 1f)); // Move towards target npc.TargetClosest(true); @@ -1947,7 +1951,7 @@ namespace CalamityMod.NPCs Vector2 vector98 = new Vector2(npc.Center.X, npc.Center.Y); float num795 = Main.player[npc.target].Center.X - vector98.X; float num796 = Main.player[npc.target].Center.Y - vector98.Y; - float num797 = (float)Math.Sqrt((double)(num795 * num795 + num796 * num796)); + float num797 = (float)Math.Sqrt(num795 * num795 + num796 * num796); float velocityBoost = death ? 2f : 2f * (1f - lifeRatio); float num798 = 8f + velocityBoost; if (CalamityWorld.bossRushActive) @@ -2017,7 +2021,7 @@ namespace CalamityMod.NPCs npc.ai[0] = !spin ? -7f : -4f; npc.ai[1] = !spin ? 0f : (playerLocation < 0 ? 1f : -1f); npc.ai[2] = 0f; - npc.ai[3] = !spin ? 0f : (float)Main.rand.Next(61); + npc.ai[3] = !spin ? 0f : Main.rand.Next(61); npc.localAI[1] = !spin ? 120f : 0f; npc.netUpdate = true; } @@ -2033,8 +2037,8 @@ namespace CalamityMod.NPCs // Velocity int var = 120; - float velocity = 6.28318548f / ((float)var * 0.75f); - npc.velocity = npc.velocity.RotatedBy((double)(-(double)velocity * npc.ai[1]), default); + float velocity = MathHelper.TwoPi / (var * 0.75f); + npc.velocity = npc.velocity.RotatedBy(-(double)velocity * npc.ai[1], default); npc.ai[2] += 1f; @@ -2066,7 +2070,7 @@ namespace CalamityMod.NPCs if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.25f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 12; num623++) @@ -2080,11 +2084,11 @@ namespace CalamityMod.NPCs // Projectile speed and spread float num179 = 8f; - Vector2 value9 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num180 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - value9.X; + Vector2 value9 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num180 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - value9.X; float num181 = Math.Abs(num180) * 0.1f; - float num182 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); + float num182 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - value9.Y - num181; + float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); num183 = num179 / num183; num180 *= num183; num182 *= num183; @@ -2094,11 +2098,11 @@ namespace CalamityMod.NPCs // Fire 10 projectiles in an arc for (int num186 = 0; num186 < 5; num186++) { - num180 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - value9.X; - num182 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - value9.Y; - num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); + num180 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - value9.X; + num182 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - value9.Y; + num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); num183 = num179 / num183; - num180 += (float)Main.rand.Next(-120, 121); + num180 += Main.rand.Next(-120, 121); num180 *= num183; Projectile.NewProjectile(value9.X, value9.Y, num180, -5f, ModContent.ProjectileType(), 12, 0f, Main.myPlayer, 0f, 0f); } @@ -2200,8 +2204,8 @@ namespace CalamityMod.NPCs } npc.ai[3] = 0f; npc.ai[0] = npc.ai[0] == -7f ? -8f : -2f; - npc.ai[1] = (float)num801; - npc.ai[2] = (float)num802; + npc.ai[1] = num801; + npc.ai[2] = num802; npc.netUpdate = true; npc.netSpam = 0; Block_2784: @@ -2223,8 +2227,8 @@ namespace CalamityMod.NPCs if (npc.ai[3] >= 255f) { npc.ai[3] = 255f; - npc.position.X = npc.ai[1] * 16f - (float)(npc.width / 2); - npc.position.Y = npc.ai[2] * 16f - (float)(npc.height / 2); + npc.position.X = npc.ai[1] * 16f - (npc.width / 2); + npc.position.Y = npc.ai[2] * 16f - (npc.height / 2); Main.PlaySound(SoundID.Item8, npc.Center); npc.ai[0] = npc.ai[0] == -8f ? -9f : -3f; npc.netUpdate = true; @@ -2258,7 +2262,7 @@ namespace CalamityMod.NPCs npc.ai[0] = -4f; npc.ai[1] = playerLocation < 0 ? 1f : -1f; npc.ai[2] = 0f; - npc.ai[3] = (float)Main.rand.Next(61); + npc.ai[3] = Main.rand.Next(61); } else { @@ -2298,8 +2302,8 @@ namespace CalamityMod.NPCs Vector2 vector99 = new Vector2(npc.Center.X, npc.Center.Y); float num803 = Main.player[npc.target].Center.X - vector99.X; float num804 = Main.player[npc.target].Center.Y - vector99.Y; - float num805 = (float)Math.Sqrt((double)(num803 * num803 + num804 * num804)); - float num806 = (CalamityWorld.bossRushActive ? 5f : 1f) + ((float)creeperScale * 0.1f); + float num805 = (float)Math.Sqrt(num803 * num803 + num804 * num804); + float num806 = (CalamityWorld.bossRushActive ? 5f : 1f) + (creeperScale * 0.1f); if (CalamityWorld.bossRushActive) num806 *= 1.5f; @@ -2321,7 +2325,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { // Teleport location - npc.localAI[1] += 1f + ((float)creeperScale * 0.1f); + npc.localAI[1] += 1f + (creeperScale * 0.1f); if (npc.localAI[1] >= 300f) { npc.localAI[1] = 0f; @@ -2348,7 +2352,7 @@ namespace CalamityMod.NPCs else num811 -= Main.rand.Next(min, max); - if (!WorldGen.SolidTile(num810, num811) && Collision.CanHit(new Vector2((float)(num810 * 16), (float)(num811 * 16)), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + if (!WorldGen.SolidTile(num810, num811) && Collision.CanHit(new Vector2(num810 * 16, num811 * 16), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { break; } @@ -2358,8 +2362,8 @@ namespace CalamityMod.NPCs } } npc.ai[0] = 1f; - npc.ai[1] = (float)num810; - npc.ai[2] = (float)num811; + npc.ai[1] = num810; + npc.ai[2] = num811; npc.netUpdate = true; Block_2801: ; @@ -2375,8 +2379,8 @@ namespace CalamityMod.NPCs { Main.PlaySound(SoundID.Item8, npc.Center); npc.alpha = 255; - npc.position.X = npc.ai[1] * 16f - (float)(npc.width / 2); - npc.position.Y = npc.ai[2] * 16f - (float)(npc.height / 2); + npc.position.X = npc.ai[1] * 16f - (npc.width / 2); + npc.position.Y = npc.ai[2] * 16f - (npc.height / 2); npc.ai[0] = 2f; } } @@ -2415,7 +2419,7 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedCreeperAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedCreeperAI(NPC npc, bool enraged, Mod mod, bool chaos) { // Despawn if Brain is gone if (NPC.crimsonBoss < 0) @@ -2439,7 +2443,7 @@ namespace CalamityMod.NPCs Vector2 vector100 = new Vector2(npc.Center.X, npc.Center.Y); float num812 = Main.npc[NPC.crimsonBoss].Center.X - vector100.X; float num813 = Main.npc[NPC.crimsonBoss].Center.Y - vector100.Y; - float num814 = (float)Math.Sqrt((double)(num812 * num812 + num813 * num813)); + float num814 = (float)Math.Sqrt(num812 * num812 + num813 * num813); float velocity = 9f; if (CalamityWorld.bossRushActive) velocity *= 2f; @@ -2463,7 +2467,7 @@ namespace CalamityMod.NPCs // Charge at target int creeperScale = 21 - creeperCount; // 1 to 20 - npc.ai[1] += 0.5f + ((float)creeperScale * 0.25f); + npc.ai[1] += 0.5f + (creeperScale * 0.25f); if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= 240f) { npc.ai[1] = 0f; @@ -2471,7 +2475,7 @@ namespace CalamityMod.NPCs vector100 = new Vector2(npc.Center.X, npc.Center.Y); num812 = Main.player[npc.target].Center.X - vector100.X; num813 = Main.player[npc.target].Center.Y - vector100.Y; - num814 = (float)Math.Sqrt((double)(num812 * num812 + num813 * num813)); + num814 = (float)Math.Sqrt(num812 * num812 + num813 * num813); num814 = velocity / num814; npc.velocity.X = num812 * num814; npc.velocity.Y = num813 * num814; @@ -2491,7 +2495,7 @@ namespace CalamityMod.NPCs Vector2 vector101 = new Vector2(npc.Center.X, npc.Center.Y); float num815 = Main.npc[NPC.crimsonBoss].Center.X - vector101.X; float num816 = Main.npc[NPC.crimsonBoss].Center.Y - vector101.Y; - float num817 = (float)Math.Sqrt((double)(num815 * num815 + num816 * num816)); + float num817 = (float)Math.Sqrt(num815 * num815 + num816 * num816); // Return to Brain if (num817 > 700f || (npc.justHit && !phase2)) @@ -2506,7 +2510,7 @@ namespace CalamityMod.NPCs #endregion #region Buffed Queen Bee AI - public static bool BuffedQueenBeeAI(NPC npc, Mod mod) + public static bool BuffedQueenBeeAI(NPC npc, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); bool death = CalamityWorld.death || CalamityWorld.bossRushActive; @@ -2523,11 +2527,11 @@ namespace CalamityMod.NPCs } bool enrage = false; - if (CalamityWorld.bossRushActive || !Main.player[npc.target].ZoneJungle || (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0 || Main.player[npc.target].position.Y > (float)((Main.maxTilesY - 200) * 16)) + if (CalamityWorld.bossRushActive || !Main.player[npc.target].ZoneJungle || Main.player[npc.target].position.Y < Main.worldSurface * 16.0 || Main.player[npc.target].position.Y > ((Main.maxTilesY - 200) * 16)) enrage = true; // Boost defense and damage as health decreases - int statBoost = (int)(20f * (1f - (float)npc.life / (float)npc.lifeMax)); + int statBoost = (int)(20f * (1f - npc.life / (float)npc.lifeMax)); if (death) { npc.defense = npc.defDefense + 20; @@ -2546,9 +2550,9 @@ namespace CalamityMod.NPCs // Despawn if (Main.player[npc.target].dead) { - if ((double)npc.position.Y < Main.worldSurface * 16.0 + 2000.0) + if (npc.position.Y < Main.worldSurface * 16.0 + 2000.0) npc.velocity.Y += 0.04f; - if (npc.position.X < (float)(Main.maxTilesX * 8)) + if (npc.position.X < (Main.maxTilesX * 8)) npc.velocity.X -= 0.04f; else npc.velocity.X += 0.04f; @@ -2584,8 +2588,8 @@ namespace CalamityMod.NPCs phase = 3; } } - while ((float)phase == num595); - npc.ai[0] = (float)phase; + while (phase == num595); + npc.ai[0] = phase; npc.ai[1] = 0f; npc.ai[2] = 0f; } @@ -2607,18 +2611,18 @@ namespace CalamityMod.NPCs speed += 8f; else { - if ((double)npc.life < (double)npc.lifeMax * 0.75 || death) + if (npc.life < npc.lifeMax * 0.75 || death) speed += 2f; - if ((double)npc.life < (double)npc.lifeMax * 0.5 || death) + if (npc.life < npc.lifeMax * 0.5 || death) speed += 2f; - if ((double)npc.life < (double)npc.lifeMax * 0.25 || death) + if (npc.life < npc.lifeMax * 0.25 || death) speed += 2f; } - if ((double)npc.life < (double)npc.lifeMax * 0.1 || death) + if (npc.life < npc.lifeMax * 0.1 || death) speed += 2f; // Switch to a random phase if chargeAmt has been exceeded - if (npc.ai[1] > (float)(2 * chargeAmt) && npc.ai[1] % 2f == 0f) + if (npc.ai[1] > (2 * chargeAmt) && npc.ai[1] % 2f == 0f) { npc.ai[0] = -1f; npc.ai[1] = 0f; @@ -2632,7 +2636,7 @@ namespace CalamityMod.NPCs { // Get target and initiate charge npc.TargetClosest(true); - if (Math.Abs(npc.position.Y + (float)(npc.height / 2) - (Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2))) < 20f) + if (Math.Abs(npc.position.Y + (npc.height / 2) - (Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2))) < 20f) { // Set AI variables and speed npc.localAI[0] = 1f; @@ -2640,10 +2644,10 @@ namespace CalamityMod.NPCs npc.ai[2] = 0f; // Get target location - Vector2 vector74 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num599 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector74.X; - float num600 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector74.Y; - float num601 = (float)Math.Sqrt((double)(num599 * num599 + num600 * num600)); + Vector2 vector74 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num599 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector74.X; + float num600 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector74.Y; + float num601 = (float)Math.Sqrt(num599 * num599 + num600 * num600); num601 = speed / num601; npc.velocity.X = num599 * num601; npc.velocity.Y = num600 * num601; @@ -2665,30 +2669,30 @@ namespace CalamityMod.NPCs } else { - if ((double)npc.life < (double)npc.lifeMax * 0.75 || death) + if (npc.life < npc.lifeMax * 0.75 || death) { num602 += 1f; num603 += 0.05f; } - if ((double)npc.life < (double)npc.lifeMax * 0.5 || death) + if (npc.life < npc.lifeMax * 0.5 || death) { num602 += 1f; num603 += 0.05f; } - if ((double)npc.life < (double)npc.lifeMax * 0.25 || death) + if (npc.life < npc.lifeMax * 0.25 || death) { num602 += 2f; num603 += 0.05f; } } - if ((double)npc.life < (double)npc.lifeMax * 0.1 || death) + if (npc.life < npc.lifeMax * 0.1 || death) { num602 += 2f; num603 += 0.1f; } // Velocity calculations - if (npc.position.Y + (float)(npc.height / 2) < Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2)) + if (npc.position.Y + (npc.height / 2) < Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2)) npc.velocity.Y += num603; else npc.velocity.Y -= num603; @@ -2698,10 +2702,10 @@ namespace CalamityMod.NPCs if (npc.velocity.Y > num602) npc.velocity.Y = num602; - if (Math.Abs(npc.position.X + (float)(npc.width / 2) - (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2))) > 500f) - npc.velocity.X += num603 * (float)npc.direction; - else if (Math.Abs(npc.position.X + (float)(npc.width / 2) - (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2))) < 300f) - npc.velocity.X -= num603 * (float)npc.direction; + if (Math.Abs(npc.position.X + (npc.width / 2) - (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2))) > 500f) + npc.velocity.X += num603 * npc.direction; + else if (Math.Abs(npc.position.X + (npc.width / 2) - (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2))) < 300f) + npc.velocity.X -= num603 * npc.direction; else npc.velocity.X *= 0.8f; @@ -2732,18 +2736,18 @@ namespace CalamityMod.NPCs int num604 = 500; if (enrage) num604 = 225; - else if ((double)npc.life < (double)npc.lifeMax * 0.33 || death) + else if (npc.life < npc.lifeMax * 0.33 || death) num604 = 300; - else if ((double)npc.life < (double)npc.lifeMax * 0.66) + else if (npc.life < npc.lifeMax * 0.66) num604 = 450; // Get which side of the player the boss is on int num605 = 1; - if (npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) + if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + (Main.player[npc.target].width / 2)) num605 = -1; // If boss is in correct position, slow down, if not, reset - if (npc.direction == num605 && Math.Abs(npc.position.X + (float)(npc.width / 2) - (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2))) > (float)num604) + if (npc.direction == num605 && Math.Abs(npc.position.X + (npc.width / 2) - (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2))) > num604) npc.ai[2] = 1f; // Keep moving @@ -2806,10 +2810,10 @@ namespace CalamityMod.NPCs // Get target location float num608 = 0.1f; - Vector2 vector75 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num609 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector75.X; - float num610 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 200f - vector75.Y; - float num611 = (float)Math.Sqrt((double)(num609 * num609 + num610 * num610)); + Vector2 vector75 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num609 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector75.X; + float num610 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 200f - vector75.Y; + float num611 = (float)Math.Sqrt(num609 * num609 + num610 * num610); // Go to bee spawn phase if (num611 < (death ? 400f : 300f)) @@ -2855,22 +2859,22 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); // Get target location and spawn bees from ass - Vector2 vector76 = new Vector2(npc.position.X + (float)(npc.width / 2) + (float)(Main.rand.Next(20) * npc.direction), npc.position.Y + (float)npc.height * 0.8f); - Vector2 vector77 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num612 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector77.X; - float num613 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector77.Y; - float num614 = (float)Math.Sqrt((double)(num612 * num612 + num613 * num613)); + Vector2 vector76 = new Vector2(npc.position.X + (npc.width / 2) + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); + Vector2 vector77 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num612 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector77.X; + float num613 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector77.Y; + float num614 = (float)Math.Sqrt(num612 * num612 + num613 * num613); // Bee spawn timer npc.ai[1] += 1f; - npc.ai[1] += (float)(playerNearBoss / 2); - if ((double)npc.life < (double)npc.lifeMax * 0.75 || death) + npc.ai[1] += (playerNearBoss / 2); + if (npc.life < npc.lifeMax * 0.75 || death) npc.ai[1] += 0.25f; - if ((double)npc.life < (double)npc.lifeMax * 0.5 || death) + if (npc.life < npc.lifeMax * 0.5 || death) npc.ai[1] += 0.25f; - if ((double)npc.life < (double)npc.lifeMax * 0.25 || death) + if (npc.life < npc.lifeMax * 0.25 || death) npc.ai[1] += 0.25f; - if ((double)npc.life < (double)npc.lifeMax * 0.1 || death) + if (npc.life < npc.lifeMax * 0.1 || death) npc.ai[1] += 0.25f; bool spawnBee = false; @@ -2889,7 +2893,7 @@ namespace CalamityMod.NPCs { int hornetAmt = CalamityMod.hornetList.Count; int spawnType = Main.rand.Next(210, 212); - if (npc.life < (double)npc.lifeMax * 0.66 || death) + if (npc.life < npc.lifeMax * 0.66 || death) spawnType = 210; int random = death ? 5 : 6; @@ -2897,8 +2901,8 @@ namespace CalamityMod.NPCs spawnType = CalamityMod.hornetList[Main.rand.Next(hornetAmt)]; int spawn = NPC.NewNPC((int)vector76.X, (int)vector76.Y, spawnType, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[spawn].velocity.X = (float)Main.rand.Next(-200, 201) * 0.002f; - Main.npc[spawn].velocity.Y = (float)Main.rand.Next(-200, 201) * 0.002f; + Main.npc[spawn].velocity.X = Main.rand.Next(-200, 201) * 0.002f; + Main.npc[spawn].velocity.Y = Main.rand.Next(-200, 201) * 0.002f; if (!CalamityMod.hornetList.Contains(spawnType)) Main.npc[spawn].localAI[0] = 60f; @@ -2913,9 +2917,9 @@ namespace CalamityMod.NPCs float num617 = 14f; float num618 = 0.1f; vector77 = vector76; - num612 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector77.X; - num613 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector77.Y; - num614 = (float)Math.Sqrt((double)(num612 * num612 + num613 * num613)); + num612 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector77.X; + num613 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector77.Y; + num614 = (float)Math.Sqrt(num612 * num612 + num613 * num613); num614 = num617 / num614; if (npc.velocity.X < num612) @@ -2962,21 +2966,21 @@ namespace CalamityMod.NPCs else if (npc.ai[0] == 3f) { // Get target location and shoot from ass - Vector2 vector78 = new Vector2(npc.position.X + (float)(npc.width / 2) + (float)(Main.rand.Next(20) * npc.direction), npc.position.Y + (float)npc.height * 0.8f); - Vector2 vector79 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num621 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector79.X; - float num622 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 300f - vector79.Y; - float num623 = (float)Math.Sqrt((double)(num621 * num621 + num622 * num622)); + Vector2 vector78 = new Vector2(npc.position.X + (npc.width / 2) + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); + Vector2 vector79 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num621 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector79.X; + float num622 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 300f - vector79.Y; + float num623 = (float)Math.Sqrt(num621 * num621 + num622 * num622); // Stinger fire counter npc.ai[1] += 1f; bool shoot = false; - if ((double)npc.life < (double)npc.lifeMax * 0.33 || death || enrage) + if (npc.life < npc.lifeMax * 0.33 || death || enrage) { if (npc.ai[1] % 15f == 14f) shoot = true; } - else if (npc.life < (double)npc.lifeMax * 0.66) + else if (npc.life < npc.lifeMax * 0.66) { if (npc.ai[1] % 25f == 24f) shoot = true; @@ -2985,18 +2989,18 @@ namespace CalamityMod.NPCs shoot = true; // Fire stingers - if (shoot && npc.position.Y + (float)npc.height < Main.player[npc.target].position.Y && Collision.CanHit(vector78, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + if (shoot && npc.position.Y + npc.height < Main.player[npc.target].position.Y && Collision.CanHit(vector78, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { Main.PlaySound(SoundID.Item17, npc.position); if (Main.netMode != NetmodeID.MultiplayerClient) { float num624 = CalamityWorld.bossRushActive ? 16f : 12f; - if ((double)npc.life < (double)npc.lifeMax * 0.33 || enrage || death) + if (npc.life < npc.lifeMax * 0.33 || enrage || death) num624 += 3f; - float num625 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector78.X; - float num626 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector78.Y; - float num627 = (float)Math.Sqrt((double)(num625 * num625 + num626 * num626)); + float num625 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector78.X; + float num626 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector78.Y; + float num627 = (float)Math.Sqrt(num625 * num625 + num626 * num626); num627 = num624 / num627; num625 *= num627; num626 *= num627; @@ -3016,8 +3020,8 @@ namespace CalamityMod.NPCs { num620 = CalamityWorld.bossRushActive ? 0.125f : 0.1f; vector79 = vector78; - num621 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector79.X; - num622 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector79.Y; + num621 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector79.X; + num622 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector79.Y; if (npc.velocity.X < num621) { @@ -3096,14 +3100,14 @@ namespace CalamityMod.NPCs #endregion #region Buffed Skeletron AI - public static bool BuffedSkeletronAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedSkeletronAI(NPC npc, bool enraged, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); bool configBossRushBoost = CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive; bool death = CalamityWorld.death || CalamityWorld.bossRushActive; // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; // Phases bool phase2 = lifeRatio < 0.33f || death; @@ -3119,15 +3123,15 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); npc.ai[0] = 1f; - int num155 = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + int num155 = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI, 0f, 0f, 0f, 0f, 255); Main.npc[num155].ai[0] = -1f; - Main.npc[num155].ai[1] = (float)npc.whoAmI; + Main.npc[num155].ai[1] = npc.whoAmI; Main.npc[num155].target = npc.target; Main.npc[num155].netUpdate = true; - num155 = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + num155 = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI, 0f, 0f, 0f, 0f, 255); Main.npc[num155].ai[0] = 1f; - Main.npc[num155].ai[1] = (float)npc.whoAmI; + Main.npc[num155].ai[1] = npc.whoAmI; Main.npc[num155].ai[3] = 150f; Main.npc[num155].target = npc.target; Main.npc[num155].netUpdate = true; @@ -3140,25 +3144,25 @@ namespace CalamityMod.NPCs calamityGlobalNPC.newAI[0] = 1f; Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0, 1f, -0.25f); - int num155 = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + int num155 = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI, 0f, 0f, 0f, 0f, 255); Main.npc[num155].ai[0] = -1f; if (death) Main.npc[num155].Calamity().newAI[0] = -1f; - Main.npc[num155].ai[1] = (float)npc.whoAmI; - Main.npc[num155].ai[3] = (death ? -75f : 0f); + Main.npc[num155].ai[1] = npc.whoAmI; + Main.npc[num155].ai[3] = death ? -75f : 0f; Main.npc[num155].target = npc.target; Main.npc[num155].netUpdate = true; - num155 = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + num155 = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.SkeletronHand, npc.whoAmI, 0f, 0f, 0f, 0f, 255); Main.npc[num155].ai[0] = 1f; if (death) Main.npc[num155].Calamity().newAI[0] = -1f; - Main.npc[num155].ai[1] = (float)npc.whoAmI; - Main.npc[num155].ai[3] = (death ? 75f : 150f); + Main.npc[num155].ai[1] = npc.whoAmI; + Main.npc[num155].ai[3] = death ? 75f : 150f; Main.npc[num155].target = npc.target; Main.npc[num155].netUpdate = true; } @@ -3204,7 +3208,7 @@ namespace CalamityMod.NPCs Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 66, 1f, -0.25f); Main.PlaySound(SoundID.Item66, npc.position); - Vector2 vector10 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + Vector2 vector10 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); // Fire magic bolt after teleport if (Main.netMode != NetmodeID.MultiplayerClient) @@ -3259,7 +3263,7 @@ namespace CalamityMod.NPCs { if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 value53 = npc.Center + new Vector2((float)(npc.direction * 20), 6f); + Vector2 value53 = npc.Center + new Vector2(npc.direction * 20, 6f); Vector2 vector251 = Main.player[npc.target].Center - value53; Point point12 = npc.Center.ToTileCoordinates(); Point point13 = Main.player[npc.target].Center.ToTileCoordinates(); @@ -3280,8 +3284,8 @@ namespace CalamityMod.NPCs if ((num1459 < point13.Y - num1455 || num1459 > point13.Y + num1455 || num1458 < point13.X - num1455 || num1458 > point13.X + num1455) && (num1459 < point12.Y - num1454 || num1459 > point12.Y + num1454 || num1458 < point12.X - num1454 || num1458 > point12.X + num1454) && !Main.tile[num1458, num1459].nactive()) { // New location params - calamityGlobalNPC.newAI[2] = (float)(num1458 * 16 - npc.width / 2); - calamityGlobalNPC.newAI[3] = (float)(num1459 * 16 - npc.height); + calamityGlobalNPC.newAI[2] = num1458 * 16 - npc.width / 2; + calamityGlobalNPC.newAI[3] = num1459 * 16 - npc.height; break; } } @@ -3342,22 +3346,22 @@ namespace CalamityMod.NPCs { calamityGlobalNPC.newAI[1] = 0f; Vector2 vector18 = npc.Center; - float num159 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector18.X; - float num160 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector18.Y; - float num161 = (float)Math.Sqrt((double)(num159 * num159 + num160 * num160)); + float num159 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector18.X; + float num160 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector18.Y; + float num161 = (float)Math.Sqrt(num159 * num159 + num160 * num160); if (Collision.CanHit(vector18, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { float num162 = phase2 ? 5f : 4f; if (CalamityWorld.bossRushActive) num162 *= 1.5f; - float num163 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector18.X + (float)Main.rand.Next(-20, 21); - float num164 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector18.Y + (float)Main.rand.Next(-20, 21); - float num165 = (float)Math.Sqrt((double)(num163 * num163 + num164 * num164)); + float num163 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector18.X + Main.rand.Next(-20, 21); + float num164 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector18.Y + Main.rand.Next(-20, 21); + float num165 = (float)Math.Sqrt(num163 * num163 + num164 * num164); num165 = num162 / num165; num163 *= num165; num164 *= num165; - Vector2 vector19 = new Vector2(num163 * 1f + (float)Main.rand.Next(-50, 51) * 0.01f, num164 * 1f + (float)Main.rand.Next(-50, 51) * 0.01f); + Vector2 vector19 = new Vector2(num163 * 1f + Main.rand.Next(-50, 51) * 0.01f, num164 * 1f + Main.rand.Next(-50, 51) * 0.01f); vector19.Normalize(); vector19 *= num162; vector19 += npc.velocity; @@ -3420,7 +3424,7 @@ namespace CalamityMod.NPCs npc.velocity.Y = -num170; } - if (npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) + if (npc.position.X + (npc.width / 2) > Main.player[npc.target].position.X + (Main.player[npc.target].width / 2)) { if (npc.velocity.X > 0f) npc.velocity.X *= 0.98f; @@ -3429,7 +3433,7 @@ namespace CalamityMod.NPCs npc.velocity.X = num172; } - if (npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) + if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + (Main.player[npc.target].width / 2)) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.98f; @@ -3458,14 +3462,14 @@ namespace CalamityMod.NPCs calamityGlobalNPC.newAI[1] = 0f; } - npc.rotation += (float)npc.direction * 0.3f; - Vector2 vector20 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num173 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector20.X; - float num174 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector20.Y; - float num175 = (float)Math.Sqrt((double)(num173 * num173 + num174 * num174)); + npc.rotation += npc.direction * 0.3f; + Vector2 vector20 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num173 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector20.X; + float num174 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector20.Y; + float num175 = (float)Math.Sqrt(num173 * num173 + num174 * num174); // Increase speed while charging - npc.damage = (int)((double)npc.defDamage * 1.3); + npc.damage = (int)(npc.defDamage * 1.3); float num176 = CalamityWorld.bossRushActive ? 10f : 4.5f; float velocityBoost = death ? 1f : 1f - lifeRatio; if (handsDead) @@ -3504,11 +3508,11 @@ namespace CalamityMod.NPCs { npc.damage = 1000; npc.defense = 9999; - npc.rotation += (float)npc.direction * 0.3f; - Vector2 vector21 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num177 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector21.X; - float num178 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector21.Y; - float num179 = (float)Math.Sqrt((double)(num177 * num177 + num178 * num178)); + npc.rotation += npc.direction * 0.3f; + Vector2 vector21 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num177 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector21.X; + float num178 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector21.Y; + float num179 = (float)Math.Sqrt(num177 * num177 + num178 * num178); num179 = 8f / num179; npc.velocity.X = num177 * num179; npc.velocity.Y = num178 * num179; @@ -3528,7 +3532,7 @@ namespace CalamityMod.NPCs // Emit dust if (npc.ai[1] != 2f && npc.ai[1] != 3f && num156 != 0) { - int num180 = Dust.NewDust(new Vector2(npc.position.X + (float)(npc.width / 2) - 15f - npc.velocity.X * 5f, npc.position.Y + (float)npc.height - 2f), 30, 10, 5, -npc.velocity.X * 0.2f, 3f, 0, default, 2f); + int num180 = Dust.NewDust(new Vector2(npc.position.X + (npc.width / 2) - 15f - npc.velocity.X * 5f, npc.position.Y + npc.height - 2f), 30, 10, 5, -npc.velocity.X * 0.2f, 3f, 0, default, 2f); Main.dust[num180].noGravity = true; Main.dust[num180].velocity.X = Main.dust[num180].velocity.X * 1.3f; Main.dust[num180].velocity.X = Main.dust[num180].velocity.X + npc.velocity.X * 0.4f; @@ -3548,7 +3552,7 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedSkeletronHandAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedSkeletronHandAI(NPC npc, bool enraged, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); @@ -3613,7 +3617,7 @@ namespace CalamityMod.NPCs npc.velocity.Y = -maxY; } - if (npc.position.X + (float)(npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 120f * npc.ai[0]) + if (npc.position.X + (npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 120f * npc.ai[0]) { if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; @@ -3622,7 +3626,7 @@ namespace CalamityMod.NPCs npc.velocity.X = maxX; } - if (npc.position.X + (float)(npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 120f * npc.ai[0]) + if (npc.position.X + (npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 120f * npc.ai[0]) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; @@ -3661,7 +3665,7 @@ namespace CalamityMod.NPCs npc.velocity.Y = -maxY; } - if (npc.position.X + (float)(npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0]) + if (npc.position.X + (npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0]) { if (npc.velocity.X > 0f) npc.velocity.X *= 0.92f; @@ -3670,7 +3674,7 @@ namespace CalamityMod.NPCs npc.velocity.X = maxX; } - if (npc.position.X + (float)(npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0]) + if (npc.position.X + (npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0]) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.92f; @@ -3680,20 +3684,20 @@ namespace CalamityMod.NPCs } } - Vector2 vector22 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num182 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector22.X; + Vector2 vector22 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num182 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector22.X; float num183 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector22.Y; - float num184 = (float)Math.Sqrt((double)(num182 * num182 + num183 * num183)); - npc.rotation = (float)Math.Atan2((double)num183, (double)num182) + 1.57f; + float num184 = (float)Math.Sqrt(num182 * num182 + num183 * num183); + npc.rotation = (float)Math.Atan2(num183, num182) + MathHelper.PiOver2; return false; } if (npc.ai[2] == 1f) { - Vector2 vector23 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num185 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector23.X; + Vector2 vector23 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num185 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector23.X; float num186 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector23.Y; - float num187 = (float)Math.Sqrt((double)(num185 * num185 + num186 * num186)); - npc.rotation = (float)Math.Atan2((double)num186, (double)num185) + 1.57f; + float num187 = (float)Math.Sqrt(num185 * num185 + num186 * num186); + npc.rotation = (float)Math.Atan2(num186, num185) + MathHelper.PiOver2; npc.velocity.X *= 0.95f; npc.velocity.Y -= 0.2f; @@ -3704,10 +3708,10 @@ namespace CalamityMod.NPCs { npc.TargetClosest(true); npc.ai[2] = 2f; - vector23 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num185 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector23.X; - num186 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector23.Y; - num187 = (float)Math.Sqrt((double)(num185 * num185 + num186 * num186)); + vector23 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num185 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector23.X; + num186 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector23.Y; + num187 = (float)Math.Sqrt(num185 * num185 + num186 * num186); num187 = 23f / num187; if (CalamityWorld.bossRushActive) @@ -3725,11 +3729,11 @@ namespace CalamityMod.NPCs } else if (npc.ai[2] == 4f) { - Vector2 vector24 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num188 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector24.X; + Vector2 vector24 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num188 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector24.X; float num189 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector24.Y; - float num190 = (float)Math.Sqrt((double)(num188 * num188 + num189 * num189)); - npc.rotation = (float)Math.Atan2((double)num189, (double)num188) + 1.57f; + float num190 = (float)Math.Sqrt(num188 * num188 + num189 * num189); + npc.rotation = (float)Math.Atan2(num189, num188) + MathHelper.PiOver2; npc.velocity.Y *= 0.95f; npc.velocity.X += 0.2f * -npc.ai[0]; @@ -3738,14 +3742,14 @@ namespace CalamityMod.NPCs else if (npc.velocity.X > 12f) npc.velocity.X = 12f; - if (npc.position.X + (float)(npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 500f || npc.position.X + (float)(npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) + 500f) + if (npc.position.X + (npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 500f || npc.position.X + (npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) + 500f) { npc.TargetClosest(true); npc.ai[2] = 5f; - vector24 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num188 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector24.X; - num189 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector24.Y; - num190 = (float)Math.Sqrt((double)(num188 * num188 + num189 * num189)); + vector24 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num188 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector24.X; + num189 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector24.Y; + num190 = (float)Math.Sqrt(num188 * num188 + num189 * num189); num190 = 24f / num190; if (CalamityWorld.bossRushActive) @@ -3756,7 +3760,7 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } } - else if (npc.ai[2] == 5f && ((npc.velocity.X > 0f && npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || (npc.velocity.X < 0f && npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || npc.velocity == Vector2.Zero)) + else if (npc.ai[2] == 5f && ((npc.velocity.X > 0f && npc.position.X + (npc.width / 2) > Main.player[npc.target].position.X + (Main.player[npc.target].width / 2)) || (npc.velocity.X < 0f && npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + (Main.player[npc.target].width / 2)) || npc.velocity == Vector2.Zero)) npc.ai[2] = 0f; if (ModLoader.GetMod("FargowiltasSouls") != null) @@ -3767,14 +3771,14 @@ namespace CalamityMod.NPCs #endregion #region Buffed Wall of Flesh AI - public static bool BuffedWallofFleshAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedWallofFleshAI(NPC npc, bool enraged, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); bool configBossRushBoost = CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive; bool death = CalamityWorld.death || CalamityWorld.bossRushActive; // Despawn - if (npc.position.X < 160f || npc.position.X > (float)((Main.maxTilesX - 10) * 16)) + if (npc.position.X < 160f || npc.position.X > ((Main.maxTilesX - 10) * 16)) npc.active = false; // Set Wall of Flesh variables @@ -3786,7 +3790,7 @@ namespace CalamityMod.NPCs } // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; // Phases based on HP bool phase2 = lifeRatio < 0.66f || death; @@ -3812,21 +3816,21 @@ namespace CalamityMod.NPCs npc.ai[2] += 1f; npc.ai[1] = 0f; - if (npc.ai[2] > (float)num330) + if (npc.ai[2] > num330) npc.ai[2] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) { - int num331 = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)(npc.height / 2) + 20f), NPCID.LeechHead, 1, 0f, 0f, 0f, 0f, 255); - Main.npc[num331].velocity.X = (float)(npc.direction * 9); + int num331 = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)(npc.position.Y + (npc.height / 2) + 20f), NPCID.LeechHead, 1, 0f, 0f, 0f, 0f, 255); + Main.npc[num331].velocity.X = npc.direction * 9; } } // Play sound npc.localAI[3] += 1f; - if (npc.localAI[3] >= (float)(600 + Main.rand.Next(1000))) + if (npc.localAI[3] >= (600 + Main.rand.Next(1000))) { - npc.localAI[3] = (float)-(float)Main.rand.Next(200); + npc.localAI[3] = -Main.rand.Next(200); Main.PlaySound(4, (int)npc.position.X, (int)npc.position.Y, 10, 1f, 0f); } @@ -3835,8 +3839,8 @@ namespace CalamityMod.NPCs // Set eye positions int num332 = (int)(npc.position.X / 16f); - int num333 = (int)((npc.position.X + (float)npc.width) / 16f); - int num334 = (int)((npc.position.Y + (float)(npc.height / 2)) / 16f); + int num333 = (int)((npc.position.X + npc.width) / 16f); + int num334 = (int)((npc.position.Y + (npc.height / 2)) / 16f); int num335 = 0; int num336 = num334 + 7; while (num335 < 15 && num336 > Main.maxTilesY - 200) @@ -3906,7 +3910,7 @@ namespace CalamityMod.NPCs } // Set Y velocity and position - float num339 = (float)((Main.wofB + Main.wofT) / 2 - npc.height / 2); + float num339 = (Main.wofB + Main.wofT) / 2 - npc.height / 2; if (npc.position.Y > num339 + 1f) npc.velocity.Y = -1f; @@ -3915,12 +3919,12 @@ namespace CalamityMod.NPCs npc.velocity.Y = 0f; int num340 = (Main.maxTilesY - 180) * 16; - if (num339 < (float)num340) - num339 = (float)num340; + if (num339 < num340) + num339 = num340; npc.position.Y = num339; - float targetPosition = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float npcPosition = npc.position.X + (float)(npc.width / 2); + float targetPosition = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float npcPosition = npc.position.X + (npc.width / 2); // Speed up if target is too far or if they're hiding behind tiles, slow down if too close float distanceFromTarget; @@ -4006,7 +4010,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X == 0f) { npc.TargetClosest(true); - npc.velocity.X = (float)npc.direction; + npc.velocity.X = npc.direction; } if (npc.velocity.X < 0f) { @@ -4021,23 +4025,23 @@ namespace CalamityMod.NPCs // Direction npc.spriteDirection = npc.direction; - Vector2 vector37 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num342 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector37.X; - float num343 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector37.Y; - float num344 = (float)Math.Sqrt((double)(num342 * num342 + num343 * num343)); + Vector2 vector37 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num342 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector37.X; + float num343 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector37.Y; + float num344 = (float)Math.Sqrt(num342 * num342 + num343 * num343); num342 *= num344; num343 *= num344; // Rotation based on direction if (npc.direction > 0) { - if (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) > npc.position.X + (float)(npc.width / 2)) - npc.rotation = (float)Math.Atan2((double)-(double)num343, (double)-(double)num342) + 3.14f; + if (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) > npc.position.X + (npc.width / 2)) + npc.rotation = (float)Math.Atan2(-num343, -num342) + MathHelper.Pi; else npc.rotation = 0f; } - else if (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) < npc.position.X + (float)(npc.width / 2)) - npc.rotation = (float)Math.Atan2((double)num343, (double)num342) + 3.14f; + else if (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) < npc.position.X + (npc.width / 2)) + npc.rotation = (float)Math.Atan2(num343, num342) + MathHelper.Pi; else npc.rotation = 0f; @@ -4059,7 +4063,7 @@ namespace CalamityMod.NPCs chance = (chance * 3 + 60) / 4; // Range of 60 to 268 - chance = (int)((double)chance * 2D); + chance = (int)(chance * 2D); if (Main.rand.Next(chance) == 0) { @@ -4081,7 +4085,7 @@ namespace CalamityMod.NPCs for (int num349 = 0; num349 < 1000; num349++) { int num350 = Main.rand.Next(10); - float num351 = (float)num350 * 0.1f - 0.05f; + float num351 = num350 * 0.1f - 0.05f; bool flag29 = true; for (int num352 = 0; num352 < num346; num352++) { @@ -4100,7 +4104,7 @@ namespace CalamityMod.NPCs if (num348 >= 0) { int num353 = NPC.NewNPC((int)npc.position.X, (int)num339, NPCID.TheHungry, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num353].ai[0] = (float)num348 * 0.1f - 0.05f; + Main.npc[num353].ai[0] = num348 * 0.1f - 0.05f; } } } @@ -4111,24 +4115,24 @@ namespace CalamityMod.NPCs { npc.localAI[0] = 2f; - num339 = (float)((Main.wofB + Main.wofT) / 2); - num339 = (num339 + (float)Main.wofT) / 2f; + num339 = (Main.wofB + Main.wofT) / 2; + num339 = (num339 + Main.wofT) / 2f; int num354 = NPC.NewNPC((int)npc.position.X, (int)num339, NPCID.WallofFleshEye, npc.whoAmI, 0f, 0f, 0f, 0f, 255); Main.npc[num354].ai[0] = 1f; - num339 = (float)((Main.wofB + Main.wofT) / 2); - num339 = (num339 + (float)Main.wofB) / 2f; + num339 = (Main.wofB + Main.wofT) / 2; + num339 = (num339 + Main.wofB) / 2f; num354 = NPC.NewNPC((int)npc.position.X, (int)num339, NPCID.WallofFleshEye, npc.whoAmI, 0f, 0f, 0f, 0f, 255); Main.npc[num354].ai[0] = -1f; - num339 = (float)((Main.wofB + Main.wofT) / 2); - num339 = (num339 + (float)Main.wofB) / 2f; + num339 = (Main.wofB + Main.wofT) / 2; + num339 = (num339 + Main.wofB) / 2f; int num; for (int num355 = 0; num355 < 11; num355 = num + 1) { num354 = NPC.NewNPC((int)npc.position.X, (int)num339, NPCID.TheHungry, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num354].ai[0] = (float)num355 * 0.1f - 0.05f; + Main.npc[num354].ai[0] = num355 * 0.1f - 0.05f; num = num355; } } @@ -4139,7 +4143,7 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedWallofFleshEyeAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedWallofFleshEyeAI(NPC npc, bool enraged, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); bool configBossRushBoost = CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive; @@ -4165,12 +4169,12 @@ namespace CalamityMod.NPCs npc.direction = Main.npc[Main.wof].direction; npc.spriteDirection = npc.direction; - float num356 = (float)((Main.wofB + Main.wofT) / 2); + float num356 = (Main.wofB + Main.wofT) / 2; if (npc.ai[0] > 0f) - num356 = (num356 + (float)Main.wofT) / 2f; + num356 = (num356 + Main.wofT) / 2f; else - num356 = (num356 + (float)Main.wofB) / 2f; - num356 -= (float)(npc.height / 2); + num356 = (num356 + Main.wofB) / 2f; + num356 -= npc.height / 2; if (npc.position.Y > num356 + 1f) npc.velocity.Y = -1f; @@ -4187,10 +4191,10 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < -5f) npc.velocity.Y = -5f; - Vector2 vector38 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num357 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector38.X; - float num358 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector38.Y; - float num359 = (float)Math.Sqrt((double)(num357 * num357 + num358 * num358)); + Vector2 vector38 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num357 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector38.X; + float num358 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector38.Y; + float num359 = (float)Math.Sqrt(num357 * num357 + num358 * num358); num357 *= num359; num358 *= num359; @@ -4198,16 +4202,16 @@ namespace CalamityMod.NPCs bool flag30 = true; if (npc.direction > 0) { - if (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) > npc.position.X + (float)(npc.width / 2)) - npc.rotation = (float)Math.Atan2((double)-(double)num358, (double)-(double)num357) + 3.14f; + if (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) > npc.position.X + (npc.width / 2)) + npc.rotation = (float)Math.Atan2(-num358, -num357) + MathHelper.Pi; else { npc.rotation = 0f; flag30 = false; } } - else if (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) < npc.position.X + (float)(npc.width / 2)) - npc.rotation = (float)Math.Atan2((double)num358, (double)num357) + 3.14f; + else if (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) < npc.position.X + (npc.width / 2)) + npc.rotation = (float)Math.Atan2(num358, num357) + MathHelper.Pi; else { npc.rotation = 0f; @@ -4218,7 +4222,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient && Main.npc[Main.wof].ai[3] == 0f) { // Percent life remaining - float lifeRatio = (float)Main.npc[Main.wof].life / (float)Main.npc[Main.wof].lifeMax; + float lifeRatio = Main.npc[Main.wof].life / (float)Main.npc[Main.wof].lifeMax; float shootBoost = death ? 3f : 4f * (1f - lifeRatio); npc.localAI[1] += 1f + shootBoost; @@ -4250,10 +4254,10 @@ namespace CalamityMod.NPCs damage += 2; int projectileType = phase2 ? ProjectileID.DeathLaser : ProjectileID.EyeLaser; - vector38 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num357 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector38.X; - num358 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector38.Y; - num359 = (float)Math.Sqrt((double)(num357 * num357 + num358 * num358)); + vector38 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num357 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector38.X; + num358 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector38.Y; + num359 = (float)Math.Sqrt(num357 * num357 + num358 * num358); num359 = velocity / num359; num357 *= num359; num358 *= num359; @@ -4272,7 +4276,7 @@ namespace CalamityMod.NPCs #endregion #region Buffed Destroyer AI - public static bool BuffedDestroyerAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedDestroyerAI(NPC npc, bool enraged, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); bool configBossRushBoost = CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive; @@ -4283,7 +4287,7 @@ namespace CalamityMod.NPCs calamityGlobalNPC.newAI[1] += 1f; // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; // Phases based on life percentage bool phase2 = lifeRatio < 0.66f || death; @@ -4384,7 +4388,7 @@ namespace CalamityMod.NPCs // Spawn segments from head if (npc.ai[0] == 0f && npc.type == NPCID.TheDestroyer) { - npc.ai[3] = (float)npc.whoAmI; + npc.ai[3] = npc.whoAmI; npc.realLife = npc.whoAmI; int num2 = npc.whoAmI; @@ -4395,11 +4399,11 @@ namespace CalamityMod.NPCs if (j == num3) num4 = NPCID.TheDestroyerTail; - int num5 = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), num4, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num5].ai[3] = (float)npc.whoAmI; + int num5 = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)(npc.position.Y + npc.height), num4, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[num5].ai[3] = npc.whoAmI; Main.npc[num5].realLife = npc.whoAmI; - Main.npc[num5].ai[1] = (float)num2; - Main.npc[num2].ai[0] = (float)num5; + Main.npc[num5].ai[1] = num2; + Main.npc[num2].ai[0] = num5; NetMessage.SendData(23, -1, -1, null, num5, 0f, 0f, 0f, 0, 0, 0); num2 = num5; } @@ -4409,14 +4413,14 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.TheDestroyerBody && Vector2.Distance(player.Center, npc.Center) > (flyAtTarget ? 320f : 80f)) { // Laser rate of fire - int shootTime = 1 + (int)Math.Ceiling(((enraged || configBossRushBoost) ? 7D : 3D) * (double)lifeRatio); + int shootTime = 1 + (int)Math.Ceiling(((enraged || configBossRushBoost) ? 7D : 3D) * lifeRatio); if (CalamityWorld.bossRushActive) shootTime += 1; - calamityGlobalNPC.newAI[0] += (float)Main.rand.Next(shootTime); + calamityGlobalNPC.newAI[0] += Main.rand.Next(shootTime); int randomCount = death ? Main.rand.Next(1470, 27300) : Main.rand.Next(1330, 24700); - if (calamityGlobalNPC.newAI[0] >= (float)randomCount) + if (calamityGlobalNPC.newAI[0] >= randomCount) { calamityGlobalNPC.newAI[0] = 0f; npc.TargetClosest(true); @@ -4481,10 +4485,10 @@ namespace CalamityMod.NPCs damage += 2; // Get target vector - Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)(npc.height / 2)); - float num6 = player.position.X + (float)player.width * 0.5f - vector.X; - float num7 = player.position.Y + (float)player.height * 0.5f - vector.Y; - float num8 = (float)Math.Sqrt((double)(num6 * num6 + num7 * num7)); + Vector2 vector = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + (npc.height / 2)); + float num6 = player.position.X + player.width * 0.5f - vector.X; + float num7 = player.position.Y + player.height * 0.5f - vector.Y; + float num8 = (float)Math.Sqrt(num6 * num6 + num7 * num7); num8 = projectileSpeed / num8; num6 *= num8; num7 *= num8; @@ -4512,9 +4516,9 @@ namespace CalamityMod.NPCs } int num12 = (int)(npc.position.X / 16f) - 1; - int num13 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; + int num13 = (int)((npc.position.X + npc.width) / 16f) + 2; int num14 = (int)(npc.position.Y / 16f) - 1; - int num15 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; + int num15 = (int)((npc.position.Y + npc.height) / 16f) + 2; if (num12 < 0) num12 = 0; @@ -4533,12 +4537,12 @@ namespace CalamityMod.NPCs { for (int l = num14; l < num15; l++) { - if (Main.tile[k, l] != null && ((Main.tile[k, l].nactive() && (Main.tileSolid[(int)Main.tile[k, l].type] || (Main.tileSolidTop[(int)Main.tile[k, l].type] && Main.tile[k, l].frameY == 0))) || Main.tile[k, l].liquid > 64)) + if (Main.tile[k, l] != null && ((Main.tile[k, l].nactive() && (Main.tileSolid[Main.tile[k, l].type] || (Main.tileSolidTop[Main.tile[k, l].type] && Main.tile[k, l].frameY == 0))) || Main.tile[k, l].liquid > 64)) { Vector2 vector2; - vector2.X = (float)(k * 16); - vector2.Y = (float)(l * 16); - if (npc.position.X + (float)npc.width > vector2.X && npc.position.X < vector2.X + 16f && npc.position.Y + (float)npc.height > vector2.Y && npc.position.Y < vector2.Y + 16f) + vector2.X = k * 16; + vector2.Y = l * 16; + if (npc.position.X + npc.width > vector2.X && npc.position.X < vector2.X + 16f && npc.position.Y + npc.height > vector2.Y && npc.position.Y < vector2.Y + 16f) { flag2 = true; break; @@ -4552,7 +4556,7 @@ namespace CalamityMod.NPCs if (!flag2) { if (npc.type != NPCID.TheDestroyerBody || npc.ai[2] != 1f) - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.3f, 0.1f, 0.05f); + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.3f, 0.1f, 0.05f); npc.localAI[1] = 1f; @@ -4593,13 +4597,13 @@ namespace CalamityMod.NPCs flag2 = false; npc.velocity.Y += 1f; - if ((double)npc.position.Y > Main.worldSurface * 16.0) + if (npc.position.Y > Main.worldSurface * 16.0) { npc.velocity.Y += 1f; fallSpeed = 32f; } - if ((double)npc.position.Y > Main.rockLayer * 16.0) + if (npc.position.Y > Main.rockLayer * 16.0) { for (int n = 0; n < Main.maxNPCs; n++) { @@ -4623,31 +4627,31 @@ namespace CalamityMod.NPCs turnSpeed *= 1.5f; } - Vector2 vector3 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num20 = player.position.X + (float)(player.width / 2); - float num21 = player.position.Y + (float)(player.height / 2); - num20 = (float)((int)(num20 / 16f) * 16); - num21 = (float)((int)(num21 / 16f) * 16); - vector3.X = (float)((int)(vector3.X / 16f) * 16); - vector3.Y = (float)((int)(vector3.Y / 16f) * 16); + Vector2 vector3 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num20 = player.position.X + (player.width / 2); + float num21 = player.position.Y + (player.height / 2); + num20 = (int)(num20 / 16f) * 16; + num21 = (int)(num21 / 16f) * 16; + vector3.X = (int)(vector3.X / 16f) * 16; + vector3.Y = (int)(vector3.Y / 16f) * 16; num20 -= vector3.X; num21 -= vector3.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + float num22 = (float)Math.Sqrt(num20 * num20 + num21 * num21); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector3 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num20 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector3.X; - num21 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector3.Y; + vector3 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num20 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector3.X; + num21 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector3.Y; } catch { } - npc.rotation = (float)Math.Atan2((double)num21, (double)num20) + 1.57f; - num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + npc.rotation = (float)Math.Atan2(num21, num20) + MathHelper.PiOver2; + num22 = (float)Math.Sqrt(num20 * num20 + num21 * num21); int num23 = (int)(44f * npc.scale); - num22 = (num22 - (float)num23) / num22; + num22 = (num22 - num23) / num22; num20 *= num22; num21 *= num22; npc.velocity = Vector2.Zero; @@ -4664,7 +4668,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y > fallSpeed) npc.velocity.Y = fallSpeed; - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)fallSpeed * 0.4) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.4) { if (npc.velocity.X < 0f) npc.velocity.X -= speed * 1.1f; @@ -4700,7 +4704,7 @@ namespace CalamityMod.NPCs Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f); } - num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + num22 = (float)Math.Sqrt(num20 * num20 + num21 * num21); float num25 = Math.Abs(num20); float num26 = Math.Abs(num21); float num27 = fallSpeed / num22; @@ -4725,7 +4729,7 @@ namespace CalamityMod.NPCs if (Math.Abs(npc.velocity.X) < fallSpeed / 2f) { if (npc.velocity.X == 0f) - npc.velocity.X -= (float)npc.direction; + npc.velocity.X -= npc.direction; npc.velocity.X *= 1.1f; } @@ -4762,14 +4766,14 @@ namespace CalamityMod.NPCs else if (npc.velocity.Y > num21) npc.velocity.Y -= speed; - if ((double)Math.Abs(num21) < (double)fallSpeed * 0.2 && ((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f))) + if (Math.Abs(num21) < fallSpeed * 0.2 && ((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f))) { if (npc.velocity.Y > 0f) npc.velocity.Y += speed * 2f; else npc.velocity.Y -= speed * 2f; } - if ((double)Math.Abs(num20) < (double)fallSpeed * 0.2 && ((npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f))) + if (Math.Abs(num20) < fallSpeed * 0.2 && ((npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f))) { if (npc.velocity.X > 0f) npc.velocity.X += speed * 2f; @@ -4784,7 +4788,7 @@ namespace CalamityMod.NPCs else if (npc.velocity.X > num20) npc.velocity.X -= speed * 1.1f; - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)fallSpeed * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) { if (npc.velocity.Y > 0f) npc.velocity.Y += speed; @@ -4799,7 +4803,7 @@ namespace CalamityMod.NPCs else if (npc.velocity.Y > num21) npc.velocity.Y -= speed * 1.1f; - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)fallSpeed * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) { if (npc.velocity.X > 0f) npc.velocity.X += speed; @@ -4810,7 +4814,7 @@ namespace CalamityMod.NPCs } } - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; if (npc.type == NPCID.TheDestroyer) { @@ -4841,7 +4845,7 @@ namespace CalamityMod.NPCs #endregion #region Buffed Twins AI - public static bool BuffedRetinazerAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedRetinazerAI(NPC npc, bool enraged, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); bool configBossRushBoost = CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive; @@ -4858,32 +4862,32 @@ namespace CalamityMod.NPCs if (CalamityGlobalNPC.fireEye != -1) spazAlive = Main.npc[CalamityGlobalNPC.fireEye].active; - bool enrage = (double)npc.life < (double)npc.lifeMax * (death ? 0.5 : 0.25); + bool enrage = npc.life < npc.lifeMax * (death ? 0.5 : 0.25); // I'm not commenting this entire fucking thing, already did spaz, I'm not doing ret if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(true); - float num376 = npc.position.X + (float)(npc.width / 2) - Main.player[npc.target].position.X - (float)(Main.player[npc.target].width / 2); - float num377 = npc.position.Y + (float)npc.height - 59f - Main.player[npc.target].position.Y - (float)(Main.player[npc.target].height / 2); + float num376 = npc.position.X + (npc.width / 2) - Main.player[npc.target].position.X - (Main.player[npc.target].width / 2); + float num377 = npc.position.Y + npc.height - 59f - Main.player[npc.target].position.Y - (Main.player[npc.target].height / 2); - float num378 = (float)Math.Atan2((double)num377, (double)num376) + 1.57f; + float num378 = (float)Math.Atan2(num377, num376) + MathHelper.PiOver2; if (num378 < 0f) - num378 += 6.283f; - else if ((double)num378 > 6.283) - num378 -= 6.283f; + num378 += MathHelper.TwoPi; + else if (num378 > MathHelper.TwoPi) + num378 -= MathHelper.TwoPi; float num379 = 0.1f; if (npc.rotation < num378) { - if ((double)(num378 - npc.rotation) > 3.1415) + if ((num378 - npc.rotation) > MathHelper.Pi) npc.rotation -= num379; else npc.rotation += num379; } else if (npc.rotation > num378) { - if ((double)(npc.rotation - num378) > 3.1415) + if ((npc.rotation - num378) > MathHelper.Pi) npc.rotation += num379; else npc.rotation -= num379; @@ -4893,16 +4897,16 @@ namespace CalamityMod.NPCs npc.rotation = num378; if (npc.rotation < 0f) - npc.rotation += 6.283f; - else if ((double)npc.rotation > 6.283) - npc.rotation -= 6.283f; + npc.rotation += MathHelper.TwoPi; + else if (npc.rotation > MathHelper.TwoPi) + npc.rotation -= MathHelper.TwoPi; if (npc.rotation > num378 - num379 && npc.rotation < num378 + num379) npc.rotation = num378; if (Main.rand.NextBool(5)) { - int num380 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default, 1f); + int num380 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default, 1f); Dust dust = Main.dust[num380]; dust.velocity.X *= 0.5f; dust.velocity.Y *= 0.1f; @@ -4941,13 +4945,13 @@ namespace CalamityMod.NPCs } int num384 = 1; - if (npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)Main.player[npc.target].width) + if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) num384 = -1; - Vector2 vector40 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num385 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) + (float)(num384 * 300) - vector40.X; - float num386 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 300f - vector40.Y; - float num387 = (float)Math.Sqrt((double)(num385 * num385 + num386 * num386)); + Vector2 vector40 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num385 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (num384 * 300) - vector40.X; + float num386 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 300f - vector40.Y; + float num387 = (float)Math.Sqrt(num385 * num385 + num386 * num386); float num388 = num387; num387 = num382 / num387; @@ -4989,7 +4993,7 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - else if (npc.position.Y + (float)npc.height < Main.player[npc.target].position.Y && num388 < 400f) + else if (npc.position.Y + npc.height < Main.player[npc.target].position.Y && num388 < 400f) { if (!Main.player[npc.target].dead) npc.ai[3] += 1f; @@ -4997,9 +5001,9 @@ namespace CalamityMod.NPCs if (npc.ai[3] >= 30f) { npc.ai[3] = 0f; - vector40 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num385 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector40.X; - num386 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector40.Y; + vector40 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num385 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector40.X; + num386 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector40.Y; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -5009,7 +5013,7 @@ namespace CalamityMod.NPCs num390 += 2; int num391 = ProjectileID.EyeLaser; - num387 = (float)Math.Sqrt((double)(num385 * num385 + num386 * num386)); + num387 = (float)Math.Sqrt(num385 * num385 + num386 * num386); num387 = num389 / num387; num385 *= num387; num386 *= num387; @@ -5026,10 +5030,10 @@ namespace CalamityMod.NPCs { npc.rotation = num378; float num393 = CalamityWorld.bossRushActive ? 22.5f : 15f; - Vector2 vector41 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num394 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector41.X; - float num395 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector41.Y; - float num396 = (float)Math.Sqrt((double)(num394 * num394 + num395 * num395)); + Vector2 vector41 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num394 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector41.X; + float num395 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector41.Y; + float num396 = (float)Math.Sqrt(num394 * num394 + num395 * num395); num396 = num393 / num396; npc.velocity.X = num394 * num396; npc.velocity.Y = num395 * num396; @@ -5041,17 +5045,17 @@ namespace CalamityMod.NPCs if (npc.ai[2] >= 25f) { npc.velocity *= 0.96f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) { npc.velocity.X = 0f; } - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) { npc.velocity.Y = 0f; } } else - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; if (npc.ai[2] >= 70f) { @@ -5070,7 +5074,7 @@ namespace CalamityMod.NPCs } // Enter phase 2 earlier - if ((double)npc.life < (double)npc.lifeMax * 0.7 || targetFloatingUp || death) + if (npc.life < npc.lifeMax * 0.7 || targetFloatingUp || death) { npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -5085,7 +5089,7 @@ namespace CalamityMod.NPCs if (npc.ai[0] == 1f) { npc.ai[2] += 0.005f; - if ((double)npc.ai[2] > 0.5) + if (npc.ai[2] > 0.5) npc.ai[2] = 0.5f; } else @@ -5110,15 +5114,15 @@ namespace CalamityMod.NPCs int num; for (int num397 = 0; num397 < 2; num397 = num + 1) { - Gore.NewGore(npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 143, 1f); - Gore.NewGore(npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 7, 1f); - Gore.NewGore(npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 6, 1f); + Gore.NewGore(npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 143, 1f); + Gore.NewGore(npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 7, 1f); + Gore.NewGore(npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 6, 1f); num = num397; } for (int num398 = 0; num398 < 20; num398 = num + 1) { - Dust.NewDust(npc.position, npc.width, npc.height, 5, (float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); + Dust.NewDust(npc.position, npc.width, npc.height, 5, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); num = num398; } @@ -5126,13 +5130,13 @@ namespace CalamityMod.NPCs } } - Dust.NewDust(npc.position, npc.width, npc.height, 5, (float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); + Dust.NewDust(npc.position, npc.width, npc.height, 5, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); npc.velocity *= 0.98f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) npc.velocity.Y = 0f; } else @@ -5147,7 +5151,7 @@ namespace CalamityMod.NPCs int defenseGain = spazInPhase1 ? 9999 : 20; npc.chaseable = !spazInPhase1; - npc.damage = (int)((double)npc.defDamage * 1.5); + npc.damage = (int)(npc.defDamage * 1.5); npc.defense = npc.defDefense + defenseGain; npc.HitSound = SoundID.NPCHit4; @@ -5162,10 +5166,10 @@ namespace CalamityMod.NPCs num400 *= 1.5f; } - Vector2 vector42 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num401 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector42.X; - float num402 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 300f - vector42.Y; - float num403 = (float)Math.Sqrt((double)(num401 * num401 + num402 * num402)); + Vector2 vector42 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num401 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector42.X; + float num402 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 300f - vector42.Y; + float num403 = (float)Math.Sqrt(num401 * num401 + num402 * num402); num403 = num399 / num403; num401 *= num403; num402 *= num403; @@ -5213,10 +5217,10 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - vector42 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num401 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector42.X; - num402 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector42.Y; - npc.rotation = (float)Math.Atan2((double)num402, (double)num401) - 1.57f; + vector42 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num401 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector42.X; + num402 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector42.Y; + npc.rotation = (float)Math.Atan2(num402, num401) - MathHelper.PiOver2; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -5233,7 +5237,7 @@ namespace CalamityMod.NPCs num405 += 3; int num406 = ProjectileID.DeathLaser; - num403 = (float)Math.Sqrt((double)(num401 * num401 + num402 * num402)); + num403 = (float)Math.Sqrt(num401 * num401 + num402 * num402); num403 = num404 / num403; num401 *= num403; num402 *= num403; @@ -5257,7 +5261,7 @@ namespace CalamityMod.NPCs if (npc.ai[1] == 1f) { int num408 = 1; - if (npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)Main.player[npc.target].width) + if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) num408 = -1; float num409 = 9.5f; @@ -5268,10 +5272,10 @@ namespace CalamityMod.NPCs num410 *= 1.5f; } - Vector2 vector43 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num411 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) + (float)(num408 * 340) - vector43.X; - float num412 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector43.Y; - float num413 = (float)Math.Sqrt((double)(num411 * num411 + num412 * num412)); + Vector2 vector43 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num411 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (num408 * 340) - vector43.X; + float num412 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector43.Y; + float num413 = (float)Math.Sqrt(num411 * num411 + num412 * num412); num413 = num409 / num413; num411 *= num413; num412 *= num413; @@ -5301,10 +5305,10 @@ namespace CalamityMod.NPCs npc.velocity.Y -= num410; } - vector43 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num411 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector43.X; - num412 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector43.Y; - npc.rotation = (float)Math.Atan2((double)num412, (double)num411) - 1.57f; + vector43 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num411 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector43.X; + num412 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector43.Y; + npc.rotation = (float)Math.Atan2(num412, num411) - MathHelper.PiOver2; // Enrage if (targetFloatingUp) @@ -5328,7 +5332,7 @@ namespace CalamityMod.NPCs num415 += 2; int num416 = ProjectileID.DeathLaser; - num413 = (float)Math.Sqrt((double)(num411 * num411 + num412 * num412)); + num413 = (float)Math.Sqrt(num411 * num411 + num412 * num412); num413 = num414 / num413; num411 *= num413; num412 *= num413; @@ -5375,10 +5379,10 @@ namespace CalamityMod.NPCs if (CalamityWorld.bossRushActive) num450 *= 1.5f; - Vector2 vector47 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num451 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector47.X; - float num452 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector47.Y; - float num453 = (float)Math.Sqrt((double)(num451 * num451 + num452 * num452)); + Vector2 vector47 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num451 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector47.X; + float num452 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector47.Y; + float num453 = (float)Math.Sqrt(num451 * num451 + num452 * num452); num453 = num450 / num453; npc.velocity.X = num451 * num453; npc.velocity.Y = num452 * num453; @@ -5397,14 +5401,14 @@ namespace CalamityMod.NPCs if (npc.ai[2] >= chargeTime) { npc.velocity *= 0.93f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) npc.velocity.Y = 0f; } else { - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; float fireRate = spazAlive ? 13f : 9f; if (CalamityWorld.bossRushActive) @@ -5412,10 +5416,10 @@ namespace CalamityMod.NPCs if (npc.ai[2] % fireRate == 0f) { - Vector2 vector34 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num349 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector34.X; - float num350 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector34.Y; - float num351 = (float)Math.Sqrt((double)(num349 * num349 + num350 * num350)); + Vector2 vector34 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num349 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector34.X; + float num350 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector34.Y; + float num351 = (float)Math.Sqrt(num349 * num349 + num350 * num350); if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -5427,10 +5431,10 @@ namespace CalamityMod.NPCs num354 += 3; int num355 = ModContent.ProjectileType(); - vector34 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num349 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector34.X; - num350 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector34.Y; - num351 = (float)Math.Sqrt((double)(num349 * num349 + num350 * num350)); + vector34 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num349 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector34.X; + num350 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector34.Y; + num351 = (float)Math.Sqrt(num349 * num349 + num350 * num350); num351 = num353 / num351; num349 *= num351; num350 *= num351; @@ -5472,13 +5476,13 @@ namespace CalamityMod.NPCs } int num408 = 1; - if (npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)Main.player[npc.target].width) + if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) num408 = -1; - Vector2 vector11 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num65 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) + (float)(num62 * num408) - vector11.X; - float num66 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector11.Y; - float num67 = (float)Math.Sqrt((double)(num65 * num65 + num66 * num66)); + Vector2 vector11 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num65 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (num62 * num408) - vector11.X; + float num66 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector11.Y; + float num67 = (float)Math.Sqrt(num65 * num65 + num66 * num66); num67 = num63 / num67; num65 *= num67; @@ -5528,7 +5532,7 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedSpazmatismAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedSpazmatismAI(NPC npc, bool enraged, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); bool configBossRushBoost = CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive; @@ -5545,33 +5549,33 @@ namespace CalamityMod.NPCs if (CalamityGlobalNPC.laserEye != -1) retAlive = Main.npc[CalamityGlobalNPC.laserEye].active; - bool enrage = (double)npc.life < (double)npc.lifeMax * (death ? 0.5 : 0.25); + bool enrage = npc.life < npc.lifeMax * (death ? 0.5 : 0.25); // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(true); // Rotation - float num418 = npc.position.X + (float)(npc.width / 2) - Main.player[npc.target].position.X - (float)(Main.player[npc.target].width / 2); - float num419 = npc.position.Y + (float)npc.height - 59f - Main.player[npc.target].position.Y - (float)(Main.player[npc.target].height / 2); + float num418 = npc.position.X + (npc.width / 2) - Main.player[npc.target].position.X - (Main.player[npc.target].width / 2); + float num419 = npc.position.Y + npc.height - 59f - Main.player[npc.target].position.Y - (Main.player[npc.target].height / 2); - float num420 = (float)Math.Atan2((double)num419, (double)num418) + 1.57f; + float num420 = (float)Math.Atan2(num419, num418) + MathHelper.PiOver2; if (num420 < 0f) - num420 += 6.283f; - else if ((double)num420 > 6.283) - num420 -= 6.283f; + num420 += MathHelper.TwoPi; + else if (num420 > MathHelper.TwoPi) + num420 -= MathHelper.TwoPi; float num421 = 0.15f; if (npc.rotation < num420) { - if ((double)(num420 - npc.rotation) > 3.1415) + if ((num420 - npc.rotation) > MathHelper.Pi) npc.rotation -= num421; else npc.rotation += num421; } else if (npc.rotation > num420) { - if ((double)(npc.rotation - num420) > 3.1415) + if ((npc.rotation - num420) > MathHelper.Pi) npc.rotation += num421; else npc.rotation -= num421; @@ -5581,9 +5585,9 @@ namespace CalamityMod.NPCs npc.rotation = num420; if (npc.rotation < 0f) - npc.rotation += 6.283f; - else if ((double)npc.rotation > 6.283) - npc.rotation -= 6.283f; + npc.rotation += MathHelper.TwoPi; + else if (npc.rotation > MathHelper.TwoPi) + npc.rotation -= MathHelper.TwoPi; if (npc.rotation > num420 - num421 && npc.rotation < num420 + num421) npc.rotation = num420; @@ -5591,7 +5595,7 @@ namespace CalamityMod.NPCs // Dust if (Main.rand.NextBool(5)) { - int num422 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default, 1f); + int num422 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default, 1f); Dust dust = Main.dust[num422]; dust.velocity.X *= 0.5f; dust.velocity.Y *= 0.1f; @@ -5638,13 +5642,13 @@ namespace CalamityMod.NPCs } int num426 = 1; - if (npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)Main.player[npc.target].width) + if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) num426 = -1; - Vector2 vector44 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num427 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) + (float)(num426 * 400) - vector44.X; - float num428 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector44.Y; - float num429 = (float)Math.Sqrt((double)(num427 * num427 + num428 * num428)); + Vector2 vector44 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num427 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (num426 * 400) - vector44.X; + float num428 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector44.Y; + float num429 = (float)Math.Sqrt(num427 * num427 + num428 * num428); num429 = num424 / num429; num427 *= num429; @@ -5695,9 +5699,9 @@ namespace CalamityMod.NPCs if (npc.ai[3] >= 30f) { npc.ai[3] = 0f; - vector44 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num427 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector44.X; - num428 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector44.Y; + vector44 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num427 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector44.X; + num428 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector44.Y; if (Main.netMode != NetmodeID.MultiplayerClient) { float num430 = CalamityWorld.bossRushActive ? 20f : 15f; @@ -5706,12 +5710,12 @@ namespace CalamityMod.NPCs num431 += 3; int num432 = ProjectileID.CursedFlameHostile; - num429 = (float)Math.Sqrt((double)(num427 * num427 + num428 * num428)); + num429 = (float)Math.Sqrt(num427 * num427 + num428 * num428); num429 = num430 / num429; num427 *= num429; num428 *= num429; - num427 += (float)Main.rand.Next(-10, 11) * 0.05f; - num428 += (float)Main.rand.Next(-10, 11) * 0.05f; + num427 += Main.rand.Next(-10, 11) * 0.05f; + num428 += Main.rand.Next(-10, 11) * 0.05f; vector44.X += num427 * 4f; vector44.Y += num428 * 4f; @@ -5727,10 +5731,10 @@ namespace CalamityMod.NPCs // Rotation and velocity npc.rotation = num420; float num434 = CalamityWorld.bossRushActive ? 24f : 16f; - Vector2 vector45 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num435 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector45.X; - float num436 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector45.Y; - float num437 = (float)Math.Sqrt((double)(num435 * num435 + num436 * num436)); + Vector2 vector45 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num435 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector45.X; + float num436 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector45.Y; + float num437 = (float)Math.Sqrt(num435 * num435 + num436 * num436); num437 = num434 / num437; npc.velocity.X = num435 * num437; npc.velocity.Y = num436 * num437; @@ -5746,13 +5750,13 @@ namespace CalamityMod.NPCs // Slow down npc.velocity *= 0.9f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) npc.velocity.Y = 0f; } else - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; // Charge 8 times float chargeTime = 38f; @@ -5774,7 +5778,7 @@ namespace CalamityMod.NPCs } // Enter phase 2 earlier - if ((double)npc.life < (double)npc.lifeMax * 0.7 || targetFloatingUp || death) + if (npc.life < npc.lifeMax * 0.7 || targetFloatingUp || death) { // Reset AI array and go to transition phase npc.ai[0] = 1f; @@ -5792,7 +5796,7 @@ namespace CalamityMod.NPCs if (npc.ai[0] == 1f) { npc.ai[2] += 0.005f; - if ((double)npc.ai[2] > 0.5) + if (npc.ai[2] > 0.5) npc.ai[2] = 0.5f; } else @@ -5819,15 +5823,15 @@ namespace CalamityMod.NPCs int num; for (int num438 = 0; num438 < 2; num438 = num + 1) { - Gore.NewGore(npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 144, 1f); - Gore.NewGore(npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 7, 1f); - Gore.NewGore(npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 6, 1f); + Gore.NewGore(npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 144, 1f); + Gore.NewGore(npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 7, 1f); + Gore.NewGore(npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 6, 1f); num = num438; } for (int num439 = 0; num439 < 20; num439 = num + 1) { - Dust.NewDust(npc.position, npc.width, npc.height, 5, (float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); + Dust.NewDust(npc.position, npc.width, npc.height, 5, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); num = num439; } @@ -5835,13 +5839,13 @@ namespace CalamityMod.NPCs } } - Dust.NewDust(npc.position, npc.width, npc.height, 5, (float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); + Dust.NewDust(npc.position, npc.width, npc.height, 5, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); npc.velocity *= 0.98f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) npc.velocity.Y = 0f; } @@ -5859,7 +5863,7 @@ namespace CalamityMod.NPCs npc.chaseable = !retInPhase1; // Increase defense and damage - npc.damage = (int)((double)npc.defDamage * 1.5); + npc.damage = (int)(npc.defDamage * 1.5); npc.defense = npc.defDefense + defenseGain; // Change hit sound to metal @@ -5877,13 +5881,13 @@ namespace CalamityMod.NPCs } int num442 = 1; - if (npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)Main.player[npc.target].width) + if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) num442 = -1; - Vector2 vector46 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num443 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) + (float)(num442 * 180) - vector46.X; - float num444 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector46.Y; - float num445 = (float)Math.Sqrt((double)(num443 * num443 + num444 * num444)); + Vector2 vector46 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num443 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (num442 * 180) - vector46.X; + float num444 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector46.Y; + float num445 = (float)Math.Sqrt(num443 * num443 + num444 * num444); // Boost speed if too far from target if (num445 > 300f) @@ -5965,15 +5969,15 @@ namespace CalamityMod.NPCs num447 += 3; int num448 = ModContent.ProjectileType(); - vector46 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num443 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector46.X; - num444 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector46.Y; - num445 = (float)Math.Sqrt((double)(num443 * num443 + num444 * num444)); + vector46 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num443 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector46.X; + num444 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector46.Y; + num445 = (float)Math.Sqrt(num443 * num443 + num444 * num444); num445 = num446 / num445; num443 *= num445; num444 *= num445; - num444 += (float)Main.rand.Next(-10, 11) * 0.01f; - num443 += (float)Main.rand.Next(-10, 11) * 0.01f; + num444 += Main.rand.Next(-10, 11) * 0.01f; + num443 += Main.rand.Next(-10, 11) * 0.01f; num444 += npc.velocity.Y * 0.5f; num443 += npc.velocity.X * 0.5f; vector46.X -= num443 * 1f; @@ -6011,10 +6015,10 @@ namespace CalamityMod.NPCs if (CalamityWorld.bossRushActive) num450 *= 1.5f; - Vector2 vector47 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num451 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector47.X; - float num452 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector47.Y; - float num453 = (float)Math.Sqrt((double)(num451 * num451 + num452 * num452)); + Vector2 vector47 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num451 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector47.X; + float num452 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector47.Y; + float num453 = (float)Math.Sqrt(num451 * num451 + num452 * num452); num453 = num450 / num453; npc.velocity.X = num451 * num453; npc.velocity.Y = num452 * num453; @@ -6039,13 +6043,13 @@ namespace CalamityMod.NPCs if (npc.ai[2] >= chargeTime) { npc.velocity *= 0.93f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) npc.velocity.Y = 0f; } else - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; // Charges 5 times if (npc.ai[2] >= chargeTime + 30f) @@ -6098,10 +6102,10 @@ namespace CalamityMod.NPCs if (npc.ai[2] == -1f || (!retAlive && npc.ai[3] == secondFastCharge)) num48 *= 1.3f; - Vector2 vector10 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num49 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector10.X; - float num50 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector10.Y; - float num51 = (float)Math.Sqrt((double)(num49 * num49 + num50 * num50)); + Vector2 vector10 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num49 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector10.X; + float num50 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector10.Y; + float num51 = (float)Math.Sqrt(num49 * num49 + num50 * num50); float num52 = num51; num51 = num48 / num51; @@ -6155,13 +6159,13 @@ namespace CalamityMod.NPCs if (npc.ai[2] >= num60) { npc.velocity *= 0.93f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) npc.velocity.Y = 0f; } else - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - 1.57f; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; // Charge 3 times float num61 = num60 + 25f; @@ -6197,10 +6201,10 @@ namespace CalamityMod.NPCs num64 *= 1.5f; } - Vector2 vector11 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num65 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector11.X; - float num66 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) + num62 - vector11.Y; - float num67 = (float)Math.Sqrt((double)(num65 * num65 + num66 * num66)); + Vector2 vector11 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num65 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector11.X; + float num66 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) + num62 - vector11.Y; + float num67 = (float)Math.Sqrt(num65 * num65 + num66 * num66); num67 = num63 / num67; num65 *= num67; @@ -6237,9 +6241,9 @@ namespace CalamityMod.NPCs float fireRate = retAlive ? 30f : 20f; if (npc.ai[2] % fireRate == 0f) { - Vector2 vector44 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num427 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector44.X; - float num428 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector44.Y; + Vector2 vector44 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num427 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector44.X; + float num428 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector44.Y; if (Main.netMode != NetmodeID.MultiplayerClient) { float num430 = 16f; @@ -6248,7 +6252,7 @@ namespace CalamityMod.NPCs num431 += 3; int num432 = ModContent.ProjectileType(); - float num429 = (float)Math.Sqrt((double)(num427 * num427 + num428 * num428)); + float num429 = (float)Math.Sqrt(num427 * num427 + num428 * num428); num429 = num430 / num429; num427 *= num429; num428 *= num429; @@ -6283,7 +6287,7 @@ namespace CalamityMod.NPCs #endregion #region Buffed Skeletron Prime AI - public static bool BuffedSkeletronPrimeAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedSkeletronPrimeAI(NPC npc, bool enraged, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); bool configBossRushBoost = CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive; @@ -6298,28 +6302,28 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); npc.ai[0] = 1f; - int arm = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PrimeCannon, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + int arm = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PrimeCannon, npc.whoAmI, 0f, 0f, 0f, 0f, 255); Main.npc[arm].ai[0] = -1f; - Main.npc[arm].ai[1] = (float)npc.whoAmI; + Main.npc[arm].ai[1] = npc.whoAmI; Main.npc[arm].target = npc.target; Main.npc[arm].netUpdate = true; - arm = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PrimeSaw, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + arm = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PrimeSaw, npc.whoAmI, 0f, 0f, 0f, 0f, 255); Main.npc[arm].ai[0] = 1f; - Main.npc[arm].ai[1] = (float)npc.whoAmI; + Main.npc[arm].ai[1] = npc.whoAmI; Main.npc[arm].target = npc.target; Main.npc[arm].netUpdate = true; - arm = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PrimeVice, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + arm = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PrimeVice, npc.whoAmI, 0f, 0f, 0f, 0f, 255); Main.npc[arm].ai[0] = -1f; - Main.npc[arm].ai[1] = (float)npc.whoAmI; + Main.npc[arm].ai[1] = npc.whoAmI; Main.npc[arm].target = npc.target; Main.npc[arm].ai[3] = 150f; Main.npc[arm].netUpdate = true; - arm = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PrimeLaser, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + arm = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PrimeLaser, npc.whoAmI, 0f, 0f, 0f, 0f, 255); Main.npc[arm].ai[0] = 1f; - Main.npc[arm].ai[1] = (float)npc.whoAmI; + Main.npc[arm].ai[1] = npc.whoAmI; Main.npc[arm].target = npc.target; Main.npc[arm].netUpdate = true; Main.npc[arm].ai[3] = 150f; @@ -6353,20 +6357,38 @@ namespace CalamityMod.NPCs bool allArmsDead = !cannonAlive && !laserAlive && !viceAlive && !sawAlive; npc.chaseable = allArmsDead; - // Set stats - if (npc.ai[1] == 5f) - npc.damage = 0; - else if (allArmsDead) - { - npc.damage = npc.defDamage; - npc.defense = npc.defDefense; - } - else - npc.defense = 9999; + // Set stats + if (npc.ai[1] == 5f) + npc.damage = 0; + else if (allArmsDead) + { + npc.damage = npc.defDamage; + npc.defense = npc.defDefense; + } + else + { + npc.defense = npc.defDefense + (cannonAlive ? 8 : 0) + (laserAlive ? 8 : 0) + (viceAlive ? 8 : 0) + (sawAlive ? 8 : 0); + } // Phases - bool phase2 = (double)npc.life < (double)npc.lifeMax * 0.66 || (death && allArmsDead); - bool phase3 = (double)npc.life < (double)npc.lifeMax * 0.33 || (death && allArmsDead); + bool phase2 = npc.life < npc.lifeMax * 0.66 || (death && allArmsDead); + bool phase3 = npc.life < npc.lifeMax * 0.33 || (death && allArmsDead); + + // Kill all arms if Prime Head enters phase 2 + if (phase2 && !allArmsDead) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc2 = Main.npc[i]; + if (npc2.type == NPCID.PrimeCannon || npc2.type == NPCID.PrimeLaser || npc2.type == NPCID.PrimeSaw || npc2.type == NPCID.PrimeVice) + { + npc2.life = -1; + npc2.HitEffect(0, 10.0); + npc2.active = false; + npc2.netUpdate = true; + } + } + } // Despawn if (Main.player[npc.target].dead || Math.Abs(npc.position.X - Main.player[npc.target].position.X) > 6000f || Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 6000f) @@ -6434,11 +6456,11 @@ namespace CalamityMod.NPCs if (npc.localAI[1] >= 480f) { npc.localAI[1] = 0f; - Vector2 shootFromVector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + Vector2 shootFromVector = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); int totalProjectiles = 12; float spread = MathHelper.ToRadians(30); // 30 degrees in radians = 0.523599 double startAngle = Math.Atan2(npc.velocity.X, npc.velocity.Y) - spread / 2; // Where the projectiles start spawning at, don't change this - double deltaAngle = spread / (float)totalProjectiles; // Angle between each projectile, 0.04363325 + double deltaAngle = spread / totalProjectiles; // Angle between each projectile, 0.04363325 double offsetAngle; float velocity = CalamityWorld.bossRushActive ? 6.5f : 5f; int damage = 31; @@ -6459,11 +6481,11 @@ namespace CalamityMod.NPCs // Spread of rockets if cannon is dead if (!cannonAlive) { - npc.localAI[2] += allArmsDead ? 2f : 1f; + npc.localAI[2] += allArmsDead ? 1.5f : 1f; if (phase3) - npc.localAI[2] += 1f; + npc.localAI[2] += 0.5f; - if (npc.localAI[2] >= 240f) + if (npc.localAI[2] >= 300f) { npc.localAI[2] = 0f; float num502 = CalamityWorld.bossRushActive ? 12f : 8f; @@ -6531,7 +6553,7 @@ namespace CalamityMod.NPCs npc.velocity.Y = -velocity2; } - if (npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) + 150f) + if (npc.position.X + (npc.width / 2) > Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + 150f) { if (npc.velocity.X > 0f) npc.velocity.X *= 0.98f; @@ -6541,7 +6563,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 7f) npc.velocity.X = 7f; } - if (npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - 150f) + if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - 150f) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.98f; @@ -6567,11 +6589,11 @@ namespace CalamityMod.NPCs if (npc.localAI[1] >= 45f) { npc.localAI[1] = 0f; - Vector2 shootFromVector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + Vector2 shootFromVector = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); int totalProjectiles = 12; float spread = MathHelper.ToRadians(30); // 30 degrees in radians = 0.523599 double startAngle = Math.Atan2(npc.velocity.X, npc.velocity.Y) - spread / 2; // Where the projectiles start spawning at, don't change this - double deltaAngle = spread / (float)totalProjectiles; // Angle between each projectile, 0.04363325 + double deltaAngle = spread / totalProjectiles; // Angle between each projectile, 0.04363325 double offsetAngle; float velocity = CalamityWorld.bossRushActive ? 6.5f : 5f; int damage = 31; @@ -6604,11 +6626,11 @@ namespace CalamityMod.NPCs npc.ai[1] = 4f; } - npc.rotation += (float)npc.direction * 0.3f; - Vector2 vector48 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num455 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector48.X; - float num456 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector48.Y; - float num457 = (float)Math.Sqrt((double)(num455 * num455 + num456 * num456)); + npc.rotation += npc.direction * 0.3f; + Vector2 vector48 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num455 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector48.X; + float num456 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector48.Y; + float num457 = (float)Math.Sqrt(num455 * num455 + num456 * num456); float speed = CalamityWorld.bossRushActive ? 7f : 3f; if (phase2 || CalamityWorld.bossRushActive) @@ -6620,8 +6642,8 @@ namespace CalamityMod.NPCs if (targetFloatingUp) speed += 5f; - float speedBuff = 3f + (3f * (1f - (float)npc.life / (float)npc.lifeMax)); - float speedBuff2 = 8f + (8f * (1f - (float)npc.life / (float)npc.lifeMax)); + float speedBuff = 3f + (3f * (1f - npc.life / (float)npc.lifeMax)); + float speedBuff2 = 8f + (8f * (1f - npc.life / (float)npc.lifeMax)); speed += num457 / 100f; if (speed < speedBuff) @@ -6640,12 +6662,12 @@ namespace CalamityMod.NPCs npc.damage = 1000; npc.defense = 9999; - npc.rotation += (float)npc.direction * 0.3f; + npc.rotation += npc.direction * 0.3f; - Vector2 vector49 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num458 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector49.X; - float num459 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector49.Y; - float num460 = (float)Math.Sqrt((double)(num458 * num458 + num459 * num459)); + Vector2 vector49 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num458 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector49.X; + float num459 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector49.Y; + float num460 = (float)Math.Sqrt(num458 * num458 + num459 * num459); float num461 = 10f; num461 += num460 / 100f; @@ -6668,14 +6690,14 @@ namespace CalamityMod.NPCs if (Collision.CanHit(vector16, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { float num159 = 7f; - float num160 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector16.X + (float)Main.rand.Next(-20, 21); - float num161 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector16.Y + (float)Main.rand.Next(-20, 21); - float num162 = (float)Math.Sqrt((double)(num160 * num160 + num161 * num161)); + float num160 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector16.X + Main.rand.Next(-20, 21); + float num161 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector16.Y + Main.rand.Next(-20, 21); + float num162 = (float)Math.Sqrt(num160 * num160 + num161 * num161); num162 = num159 / num162; num160 *= num162; num161 *= num162; - Vector2 value = new Vector2(num160 * 1f + (float)Main.rand.Next(-50, 51) * 0.01f, num161 * 1f + (float)Main.rand.Next(-50, 51) * 0.01f); + Vector2 value = new Vector2(num160 * 1f + Main.rand.Next(-50, 51) * 0.01f, num161 * 1f + Main.rand.Next(-50, 51) * 0.01f); value.Normalize(); value *= num159; value += npc.velocity; @@ -6725,10 +6747,10 @@ namespace CalamityMod.NPCs else if (Main.player[npc.target].velocity.X < 0f) calamityGlobalNPC.newAI[0] = -1f; else - calamityGlobalNPC.newAI[0] = (float)Main.player[npc.target].direction; + calamityGlobalNPC.newAI[0] = Main.player[npc.target].direction; // Set spin velocity - npc.velocity.X = 3.14159265f * npc.ai[3] / spinVelocity; + npc.velocity.X = MathHelper.Pi * npc.ai[3] / spinVelocity; npc.velocity *= -calamityGlobalNPC.newAI[0]; npc.netUpdate = true; } @@ -6736,7 +6758,7 @@ namespace CalamityMod.NPCs // Spawn 6 Probes and maintain velocity, or spit skulls if probes are alive else { - npc.velocity = npc.velocity.RotatedBy(3.14159265 / spinVelocity * -calamityGlobalNPC.newAI[0]); + npc.velocity = npc.velocity.RotatedBy(MathHelper.Pi / spinVelocity * -calamityGlobalNPC.newAI[0]); if (npc.ai[2] % 30f == 0f) { calamityGlobalNPC.newAI[1] += 1f; @@ -6751,14 +6773,14 @@ namespace CalamityMod.NPCs { Vector2 vector16 = npc.Center; float num159 = CalamityWorld.bossRushActive ? 6f : 4f; - float num160 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector16.X + (float)Main.rand.Next(-20, 21); - float num161 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector16.Y + (float)Main.rand.Next(-20, 21); - float num162 = (float)Math.Sqrt((double)(num160 * num160 + num161 * num161)); + float num160 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector16.X + Main.rand.Next(-20, 21); + float num161 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector16.Y + Main.rand.Next(-20, 21); + float num162 = (float)Math.Sqrt(num160 * num160 + num161 * num161); num162 = num159 / num162; num160 *= num162; num161 *= num162; - Vector2 value = new Vector2(num160 * 1f + (float)Main.rand.Next(-50, 51) * 0.01f, num161 * 1f + (float)Main.rand.Next(-50, 51) * 0.01f); + Vector2 value = new Vector2(num160 * 1f + Main.rand.Next(-50, 51) * 0.01f, num161 * 1f + Main.rand.Next(-50, 51) * 0.01f); value.Normalize(); value *= num159; num160 = value.X; @@ -6808,7 +6830,7 @@ namespace CalamityMod.NPCs float posX = Main.player[npc.target].Center.X - center.X; float posY = Main.player[npc.target].Center.Y - center.Y - 500f; - float distance = (float)Math.Sqrt((double)(posX * posX + posY * posY)); + float distance = (float)Math.Sqrt(posX * posX + posY * posY); if (distance < 20f) { posX = npc.velocity.X; @@ -6853,7 +6875,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 velocity = new Vector2(-1f * (float)Main.rand.NextDouble() * 3f, 1f); - velocity = velocity.RotatedBy((Main.rand.NextDouble() - 0.5) * 0.78539818525314331, default); + velocity = velocity.RotatedBy((Main.rand.NextDouble() - 0.5) * MathHelper.PiOver4, default); velocity *= CalamityWorld.bossRushActive ? 7.5f : 5f; int damage = 33; if (death) @@ -6884,7 +6906,7 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedPrimeLaserAI(NPC npc, Mod mod) + public static bool BuffedPrimeLaserAI(NPC npc, Mod mod, bool chaos) { bool death = CalamityWorld.death || CalamityWorld.bossRushActive; @@ -6970,7 +6992,7 @@ namespace CalamityMod.NPCs npc.velocity.Y = -2.5f; } - if (npc.position.X + (float)(npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 180f * npc.ai[0]) + if (npc.position.X + (npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 180f * npc.ai[0]) { if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; @@ -6980,7 +7002,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 7f) npc.velocity.X = 7f; } - if (npc.position.X + (float)(npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 180f * npc.ai[0]) + if (npc.position.X + (npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 180f * npc.ai[0]) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; @@ -6992,11 +7014,11 @@ namespace CalamityMod.NPCs } npc.TargetClosest(true); - Vector2 vector62 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num506 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector62.X; - float num507 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector62.Y; - float num508 = (float)Math.Sqrt((double)(num506 * num506 + num507 * num507)); - npc.rotation = (float)Math.Atan2((double)num507, (double)num506) - 1.57f; + Vector2 vector62 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num506 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector62.X; + float num507 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector62.Y; + float num508 = (float)Math.Sqrt(num506 * num506 + num507 * num507); + npc.rotation = (float)Math.Atan2(num507, num506) - MathHelper.PiOver2; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -7050,10 +7072,10 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - Vector2 vector63 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num513 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - 350f - vector63.X; - float num514 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 120f - vector63.Y; // Used to be 20f - float num515 = (float)Math.Sqrt((double)(num513 * num513 + num514 * num514)); + Vector2 vector63 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num513 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - 350f - vector63.X; + float num514 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 120f - vector63.Y; // Used to be 20f + float num515 = (float)Math.Sqrt(num513 * num513 + num514 * num514); num515 = (CalamityWorld.bossRushActive ? 10f : 7f) / num515; num513 *= num515; num514 *= num515; @@ -7084,11 +7106,11 @@ namespace CalamityMod.NPCs } npc.TargetClosest(true); - vector63 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num513 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector63.X; - num514 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector63.Y; - num515 = (float)Math.Sqrt((double)(num513 * num513 + num514 * num514)); - npc.rotation = (float)Math.Atan2((double)num514, (double)num513) - 1.57f; + vector63 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num513 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector63.X; + num514 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector63.Y; + num515 = (float)Math.Sqrt(num513 * num513 + num514 * num514); + npc.rotation = (float)Math.Atan2(num514, num513) - MathHelper.PiOver2; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -7104,11 +7126,11 @@ namespace CalamityMod.NPCs if (npc.localAI[0] >= 120f) { npc.localAI[0] = 0f; - Vector2 shootFromVector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + Vector2 shootFromVector = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); int totalProjectiles = 12; float spread = MathHelper.ToRadians(30); // 30 degrees in radians = 0.523599 double startAngle = Math.Atan2(npc.velocity.X, npc.velocity.Y) - spread / 2; // Where the projectiles start spawning at, don't change this - double deltaAngle = spread / (float)totalProjectiles; // Angle between each projectile, 0.04363325 + double deltaAngle = spread / totalProjectiles; // Angle between each projectile, 0.04363325 double offsetAngle; float velocity = CalamityWorld.bossRushActive ? 6.5f : 5f; int damage = 31; @@ -7131,7 +7153,7 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedPrimeCannonAI(NPC npc, Mod mod) + public static bool BuffedPrimeCannonAI(NPC npc, Mod mod, bool chaos) { bool death = CalamityWorld.death || CalamityWorld.bossRushActive; @@ -7252,7 +7274,7 @@ namespace CalamityMod.NPCs npc.velocity.Y = -2.5f; } - if (npc.position.X + (float)(npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) + 200f) + if (npc.position.X + (npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) + 200f) { if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; @@ -7262,7 +7284,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 7f) npc.velocity.X = 7f; } - if (npc.position.X + (float)(npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) + 160f) + if (npc.position.X + (npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) + 160f) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; @@ -7273,11 +7295,11 @@ namespace CalamityMod.NPCs npc.velocity.X = -7f; } - Vector2 vector60 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num492 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector60.X; - float num493 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector60.Y; - float num494 = (float)Math.Sqrt((double)(num492 * num492 + num493 * num493)); - npc.rotation = (float)Math.Atan2((double)num493, (double)num492) - 1.57f; + Vector2 vector60 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num492 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector60.X; + float num493 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector60.Y; + float num494 = (float)Math.Sqrt(num492 * num492 + num493 * num493); + npc.rotation = (float)Math.Atan2(num493, num492) - MathHelper.PiOver2; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -7310,11 +7332,11 @@ namespace CalamityMod.NPCs else { - Vector2 vector61 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num499 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector61.X; + Vector2 vector61 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num499 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector61.X; float num500 = Main.npc[(int)npc.ai[1]].position.Y - vector61.Y; - num500 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 80f - vector61.Y; - float num501 = (float)Math.Sqrt((double)(num499 * num499 + num500 * num500)); + num500 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 80f - vector61.Y; + float num501 = (float)Math.Sqrt(num499 * num499 + num500 * num500); num501 = (CalamityWorld.bossRushActive ? 10f : 7f) / num501; num499 *= num501; num500 *= num501; @@ -7345,11 +7367,11 @@ namespace CalamityMod.NPCs } npc.TargetClosest(true); - vector61 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num499 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector61.X; - num500 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector61.Y; - num501 = (float)Math.Sqrt((double)(num499 * num499 + num500 * num500)); - npc.rotation = (float)Math.Atan2((double)num500, (double)num499) - 1.57f; + vector61 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num499 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector61.X; + num500 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector61.Y; + num501 = (float)Math.Sqrt(num499 * num499 + num500 * num500); + npc.rotation = (float)Math.Atan2(num500, num499) - MathHelper.PiOver2; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -7390,16 +7412,16 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedPrimeViceAI(NPC npc, Mod mod) + public static bool BuffedPrimeViceAI(NPC npc, Mod mod, bool chaos) { // Direction npc.spriteDirection = -(int)npc.ai[0]; // Where the vice should be in relation to the head - Vector2 vector55 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num477 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector55.X; + Vector2 vector55 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num477 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector55.X; float num478 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector55.Y; - float num479 = (float)Math.Sqrt((double)(num477 * num477 + num478 * num478)); + float num479 = (float)Math.Sqrt(num477 * num477 + num478 * num478); // Return the vice to its proper location in relation to the head if it's too far away if (npc.ai[2] != 99f) @@ -7468,7 +7490,7 @@ namespace CalamityMod.NPCs npc.velocity.Y = -7f; } - if (npc.position.X + (float)(npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2)) + if (npc.position.X + (npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2)) { if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; @@ -7478,7 +7500,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 10f) npc.velocity.X = 10f; } - if (npc.position.X + (float)(npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2)) + if (npc.position.X + (npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2)) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; @@ -7537,7 +7559,7 @@ namespace CalamityMod.NPCs npc.velocity.Y = -2.5f; } - if (npc.position.X + (float)(npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) + 250f) + if (npc.position.X + (npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) + 250f) { if (npc.velocity.X > 0f) npc.velocity.X *= 0.94f; @@ -7547,7 +7569,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 8f) npc.velocity.X = 8f; } - if (npc.position.X + (float)(npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2)) + if (npc.position.X + (npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2)) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.94f; @@ -7558,11 +7580,11 @@ namespace CalamityMod.NPCs npc.velocity.X = -7f; } - Vector2 vector57 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num483 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector57.X; + Vector2 vector57 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num483 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector57.X; float num484 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector57.Y; - float num485 = (float)Math.Sqrt((double)(num483 * num483 + num484 * num484)); - npc.rotation = (float)Math.Atan2((double)num484, (double)num483) + 1.57f; + float num485 = (float)Math.Sqrt(num483 * num483 + num484 * num484); + npc.rotation = (float)Math.Atan2(num484, num483) + MathHelper.PiOver2; return false; } @@ -7572,11 +7594,11 @@ namespace CalamityMod.NPCs if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.9f; - Vector2 vector58 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num486 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 280f * npc.ai[0] - vector58.X; + Vector2 vector58 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num486 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 280f * npc.ai[0] - vector58.X; float num487 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector58.Y; - float num488 = (float)Math.Sqrt((double)(num486 * num486 + num487 * num487)); - npc.rotation = (float)Math.Atan2((double)num487, (double)num486) + 1.57f; + float num488 = (float)Math.Sqrt(num486 * num486 + num487 * num487); + npc.rotation = (float)Math.Atan2(num487, num486) + MathHelper.PiOver2; npc.velocity.X = (npc.velocity.X * 5f + Main.npc[(int)npc.ai[1]].velocity.X) / 6f; npc.velocity.X += 0.5f; @@ -7597,10 +7619,10 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); npc.ai[2] = 2f; - vector58 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num486 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector58.X; - num487 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector58.Y; - num488 = (float)Math.Sqrt((double)(num486 * num486 + num487 * num487)); + vector58 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num486 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector58.X; + num487 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector58.Y; + num488 = (float)Math.Sqrt(num486 * num486 + num487 * num487); num488 = chargeVelocity / num488; npc.velocity.X = num486 * num488; npc.velocity.Y = num487 * num488; @@ -7637,11 +7659,11 @@ namespace CalamityMod.NPCs // Different type of charge else if (npc.ai[2] == 4f) { - Vector2 vector59 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num489 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector59.X; + Vector2 vector59 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num489 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector59.X; float num490 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector59.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - npc.rotation = (float)Math.Atan2((double)num490, (double)num489) + 1.57f; + float num491 = (float)Math.Sqrt(num489 * num489 + num490 * num490); + npc.rotation = (float)Math.Atan2(num490, num489) + MathHelper.PiOver2; npc.velocity.Y = (npc.velocity.Y * 5f + Main.npc[(int)npc.ai[1]].velocity.Y) / 6f; @@ -7649,7 +7671,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 12f) npc.velocity.X = 12f; - if (npc.position.X + (float)(npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 500f || npc.position.X + (float)(npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) + 500f) + if (npc.position.X + (npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 500f || npc.position.X + (npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) + 500f) { float chargeVelocity = CalamityWorld.bossRushActive ? 21f : 14f; if (!cannonAlive) @@ -7661,10 +7683,10 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); npc.ai[2] = 5f; - vector59 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num489 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector59.X; - num490 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector59.Y; - num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); + vector59 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num489 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector59.X; + num490 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector59.Y; + num491 = (float)Math.Sqrt(num489 * num489 + num490 * num490); num491 = chargeVelocity / num491; npc.velocity.X = num489 * num491; npc.velocity.Y = num490 * num491; @@ -7673,7 +7695,7 @@ namespace CalamityMod.NPCs } // Charge 4 times (more if arms are dead) - else if (npc.ai[2] == 5f && npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - 100f) + else if (npc.ai[2] == 5f && npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - 100f) { float chargeAmt = 4f; if (!cannonAlive) @@ -7702,12 +7724,12 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedPrimeSawAI(NPC npc, Mod mod) + public static bool BuffedPrimeSawAI(NPC npc, Mod mod, bool chaos) { - Vector2 vector50 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num462 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector50.X; + Vector2 vector50 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num462 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector50.X; float num463 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector50.Y; - float num464 = (float)Math.Sqrt((double)(num462 * num462 + num463 * num463)); + float num464 = (float)Math.Sqrt(num462 * num462 + num463 * num463); if (npc.ai[2] != 99f) { @@ -7775,7 +7797,7 @@ namespace CalamityMod.NPCs npc.velocity.Y = -7f; } - if (npc.position.X + (float)(npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2)) + if (npc.position.X + (npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2)) { if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; @@ -7785,7 +7807,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 10f) npc.velocity.X = 10f; } - if (npc.position.X + (float)(npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2)) + if (npc.position.X + (npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2)) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; @@ -7840,7 +7862,7 @@ namespace CalamityMod.NPCs npc.velocity.Y = -2.5f; } - if (npc.position.X + (float)(npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2)) + if (npc.position.X + (npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2)) { if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; @@ -7850,7 +7872,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 10f) npc.velocity.X = 10f; } - if (npc.position.X + (float)(npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 250f) + if (npc.position.X + (npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 250f) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; @@ -7861,21 +7883,21 @@ namespace CalamityMod.NPCs npc.velocity.X = -10f; } - Vector2 vector52 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num468 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector52.X; + Vector2 vector52 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num468 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector52.X; float num469 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector52.Y; - float num470 = (float)Math.Sqrt((double)(num468 * num468 + num469 * num469)); - npc.rotation = (float)Math.Atan2((double)num469, (double)num468) + 1.57f; + float num470 = (float)Math.Sqrt(num468 * num468 + num469 * num469); + npc.rotation = (float)Math.Atan2(num469, num468) + MathHelper.PiOver2; return false; } if (npc.ai[2] == 1f) { - Vector2 vector53 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num471 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector53.X; + Vector2 vector53 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num471 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector53.X; float num472 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector53.Y; - float num473 = (float)Math.Sqrt((double)(num471 * num471 + num472 * num472)); - npc.rotation = (float)Math.Atan2((double)num472, (double)num471) + 1.57f; + float num473 = (float)Math.Sqrt(num471 * num471 + num472 * num472); + npc.rotation = (float)Math.Atan2(num472, num471) + MathHelper.PiOver2; npc.velocity.X *= 0.95f; npc.velocity.Y -= 0.3f; @@ -7894,10 +7916,10 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); npc.ai[2] = 2f; - vector53 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num471 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector53.X; - num472 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector53.Y; - num473 = (float)Math.Sqrt((double)(num471 * num471 + num472 * num472)); + vector53 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num471 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector53.X; + num472 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector53.Y; + num473 = (float)Math.Sqrt(num471 * num471 + num472 * num472); num473 = chargeVelocity / num473; npc.velocity.X = num471 * num473; npc.velocity.Y = num472 * num473; @@ -7924,10 +7946,10 @@ namespace CalamityMod.NPCs chargeVelocity += 1.5f; npc.TargetClosest(true); - Vector2 vector54 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num474 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector54.X; - float num475 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector54.Y; - float num476 = (float)Math.Sqrt((double)(num474 * num474 + num475 * num475)); + Vector2 vector54 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num474 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector54.X; + float num475 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector54.Y; + float num476 = (float)Math.Sqrt(num474 * num474 + num475 * num475); num476 = chargeVelocity / num476; num474 *= num476; num475 *= num476; @@ -7968,15 +7990,15 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - vector54 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num474 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector54.X; + vector54 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num474 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector54.X; num475 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector54.Y; - num476 = (float)Math.Sqrt((double)(num474 * num474 + num475 * num475)); - npc.rotation = (float)Math.Atan2((double)num475, (double)num474) + 1.57f; + num476 = (float)Math.Sqrt(num474 * num474 + num475 * num475); + npc.rotation = (float)Math.Atan2(num475, num474) + MathHelper.PiOver2; return false; } - if (npc.ai[2] == 5f && ((npc.velocity.X > 0f && npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || (npc.velocity.X < 0f && npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)))) + if (npc.ai[2] == 5f && ((npc.velocity.X > 0f && npc.position.X + (npc.width / 2) > Main.player[npc.target].position.X + (Main.player[npc.target].width / 2)) || (npc.velocity.X < 0f && npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + (Main.player[npc.target].width / 2)))) npc.ai[2] = 0f; } } @@ -7989,13 +8011,13 @@ namespace CalamityMod.NPCs #endregion #region Buffed Plantera AI - public static bool BuffedPlanteraAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedPlanteraAI(NPC npc, bool enraged, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); bool death = CalamityWorld.death || CalamityWorld.bossRushActive; // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; // Phases based on HP bool phase2 = lifeRatio <= 0.5f; @@ -8007,7 +8029,7 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); // Check for Jungle and remaining Tentacles - bool surface = !CalamityWorld.bossRushActive && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0; + bool surface = !CalamityWorld.bossRushActive && Main.player[npc.target].position.Y < Main.worldSurface * 16.0; int tentacleCount = NPC.CountNPCS(NPCID.PlanterasTentacle); bool tentaclesDead = tentacleCount == 0; bool speedUp = Vector2.Distance(Main.player[npc.target].Center, npc.Center) > (phase3 ? 480f : 640f); // 30 or 40 tile distance @@ -8059,8 +8081,8 @@ namespace CalamityMod.NPCs break; } } - num730 /= (float)num732; - num731 /= (float)num732; + num730 /= num732; + num731 /= num732; // Velocity and acceleration float velocity = 6f; @@ -8108,7 +8130,7 @@ namespace CalamityMod.NPCs } // Enrage if target is on the surface - if (!CalamityWorld.bossRushActive && (surface || Main.player[npc.target].position.Y > (float)((Main.maxTilesY - 200) * 16))) + if (!CalamityWorld.bossRushActive && (surface || Main.player[npc.target].position.Y > ((Main.maxTilesY - 200) * 16))) { enrage = true; velocity += 8f; @@ -8141,7 +8163,7 @@ namespace CalamityMod.NPCs // Scale multiplier based on nearby active tiles float tileEnrageMult = 1f; if (nearbyActiveTiles < 800) - tileEnrageMult += (float)(800 - nearbyActiveTiles) * 0.001f; // Ranges from 1f to 1.8f + tileEnrageMult += (800 - nearbyActiveTiles) * 0.001f; // Ranges from 1f to 1.8f // Movement relative to the target and hook positions Vector2 vector91 = new Vector2(num730, num731); @@ -8153,7 +8175,7 @@ namespace CalamityMod.NPCs num736 *= -1f; velocity += 8f; } - float num738 = (float)Math.Sqrt((double)(num736 * num736 + num737 * num737)); + float num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); // Increase speed based on nearby active tiles velocity *= tileEnrageMult; @@ -8181,7 +8203,7 @@ namespace CalamityMod.NPCs vector91 = new Vector2(npc.Center.X, npc.Center.Y); num736 = num730 - vector91.X; num737 = num731 - vector91.Y; - num738 = (float)Math.Sqrt((double)(num736 * num736 + num737 * num737)); + num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); if (num738 < velocity) { @@ -8231,7 +8253,7 @@ namespace CalamityMod.NPCs Vector2 vector92 = new Vector2(npc.Center.X, npc.Center.Y); float num740 = Main.player[npc.target].Center.X - vector92.X; float num741 = Main.player[npc.target].Center.Y - vector92.Y; - npc.rotation = (float)Math.Atan2((double)num741, (double)num740) + 1.57f; + npc.rotation = (float)Math.Atan2(num741, num740) + MathHelper.PiOver2; // Phase 1 if (!phase2) @@ -8273,9 +8295,9 @@ namespace CalamityMod.NPCs { Vector2 vector93 = new Vector2(npc.Center.X, npc.Center.Y); float num742 = CalamityWorld.bossRushActive ? 27f : 18f; - float num743 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector93.X; - float num744 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector93.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num743 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector93.X; + float num744 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; num744 *= num745; @@ -8328,7 +8350,7 @@ namespace CalamityMod.NPCs { // Adjust stats npc.defense = 21; - npc.damage = (int)((float)npc.defDamage * 1.4f); + npc.damage = (int)(npc.defDamage * 1.4f); if (enrage) { npc.defense *= 4; @@ -8356,9 +8378,9 @@ namespace CalamityMod.NPCs // Spawn gore if (npc.localAI[2] == 0f) { - Gore.NewGore(new Vector2(npc.position.X + (float)Main.rand.Next(npc.width), npc.position.Y + (float)Main.rand.Next(npc.height)), npc.velocity, 378, npc.scale); - Gore.NewGore(new Vector2(npc.position.X + (float)Main.rand.Next(npc.width), npc.position.Y + (float)Main.rand.Next(npc.height)), npc.velocity, 379, npc.scale); - Gore.NewGore(new Vector2(npc.position.X + (float)Main.rand.Next(npc.width), npc.position.Y + (float)Main.rand.Next(npc.height)), npc.velocity, 380, npc.scale); + Gore.NewGore(new Vector2(npc.position.X + Main.rand.Next(npc.width), npc.position.Y + Main.rand.Next(npc.height)), npc.velocity, 378, npc.scale); + Gore.NewGore(new Vector2(npc.position.X + Main.rand.Next(npc.width), npc.position.Y + Main.rand.Next(npc.height)), npc.velocity, 379, npc.scale); + Gore.NewGore(new Vector2(npc.position.X + Main.rand.Next(npc.width), npc.position.Y + Main.rand.Next(npc.height)), npc.velocity, 380, npc.scale); npc.localAI[2] = 1f; } @@ -8369,16 +8391,16 @@ namespace CalamityMod.NPCs if (npc.localAI[1] >= 360f) { float num757 = CalamityWorld.bossRushActive ? 12f : 8f; - Vector2 vector94 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num758 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector94.X + (float)Main.rand.Next(-10, 11); + Vector2 vector94 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num758 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector94.X + Main.rand.Next(-10, 11); float num759 = Math.Abs(num758 * 0.2f); - float num760 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector94.Y + (float)Main.rand.Next(-10, 11); + float num760 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector94.Y + Main.rand.Next(-10, 11); if (num760 > 0f) num759 = 0f; num760 -= num759; - float num761 = (float)Math.Sqrt((double)(num758 * num758 + num760 * num760)); + float num761 = (float)Math.Sqrt(num758 * num758 + num760 * num760); num761 = num757 / num761; num758 *= num761; num760 *= num761; @@ -8398,23 +8420,23 @@ namespace CalamityMod.NPCs int tentacleScale = 8 - tentacleCount; // 1 to 8 if (nearbyActiveTiles > 600) - npc.localAI[3] += 0.5f + ((float)(tentacleScale - 1) * 0.5f); + npc.localAI[3] += 0.5f + ((tentacleScale - 1) * 0.5f); else - npc.localAI[3] += (nearbyActiveTiles > 300 ? 1f : 5f) + (float)(tentacleScale - 1); + npc.localAI[3] += (nearbyActiveTiles > 300 ? 1f : 5f) + (tentacleScale - 1); if (npc.localAI[3] >= 360f) { Vector2 vector93 = new Vector2(npc.Center.X, npc.Center.Y); - float num742 = 8f - ((float)tentacleScale * 0.25f); // 7.75f to 6f, slower projectiles are harder to avoid + float num742 = 8f - (tentacleScale * 0.25f); // 7.75f to 6f, slower projectiles are harder to avoid if (nearbyActiveTiles < 300) num742 = 8.5f; if (CalamityWorld.bossRushActive) num742 *= 1.5f; - float num743 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector93.X; - float num744 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector93.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num743 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector93.X; + float num744 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; num744 *= num745; @@ -8452,9 +8474,9 @@ namespace CalamityMod.NPCs Vector2 vector93 = new Vector2(npc.Center.X, npc.Center.Y); float num742 = CalamityWorld.bossRushActive ? 10f : 7f; - float num743 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector93.X; - float num744 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector93.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num743 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector93.X; + float num744 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; num744 *= num745; @@ -8473,13 +8495,13 @@ namespace CalamityMod.NPCs float rotation = MathHelper.ToRadians(spread); float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); double startAngle = Math.Atan2(num743, num744) - rotation / 2; - double deltaAngle = rotation / (float)numProj; + double deltaAngle = rotation / numProj; double offsetAngle; for (int i = 0; i < numProj; i++) { offsetAngle = startAngle + deltaAngle * i; - float ai0 = (float)Main.rand.Next(3); + float ai0 = Main.rand.Next(3); Projectile.NewProjectile(vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), ModContent.ProjectileType(), damage, 0f, Main.myPlayer, ai0, 0f); } @@ -8500,9 +8522,9 @@ namespace CalamityMod.NPCs Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 0.75f; Main.dust[dust].fadeIn = 1.3f; - Vector2 vector = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + Vector2 vector = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); vector.Normalize(); - vector *= (float)Main.rand.Next(50, 100) * 0.04f; + vector *= Main.rand.Next(50, 100) * 0.04f; Main.dust[dust].velocity = vector; vector.Normalize(); vector *= 86f; @@ -8543,7 +8565,7 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedPlanterasHookAI(NPC npc, Mod mod) + public static bool BuffedPlanterasHookAI(NPC npc, Mod mod, bool chaos) { // Variables bool enrage = false; @@ -8559,14 +8581,14 @@ namespace CalamityMod.NPCs } // Percent life remaining, Plantera - float lifeRatio = (float)Main.npc[NPC.plantBoss].life / (float)Main.npc[NPC.plantBoss].lifeMax; + float lifeRatio = Main.npc[NPC.plantBoss].life / (float)Main.npc[NPC.plantBoss].lifeMax; // Despawn if Plantera's target is dead if (Main.player[Main.npc[NPC.plantBoss].target].dead && !CalamityWorld.bossRushActive) despawn = true; // Enrage if Plantera's target is on the surface - if (!CalamityWorld.bossRushActive && (((double)Main.player[Main.npc[NPC.plantBoss].target].position.Y < Main.worldSurface * 16.0 || Main.player[Main.npc[NPC.plantBoss].target].position.Y > (float)((Main.maxTilesY - 200) * 16)) | despawn)) + if (!CalamityWorld.bossRushActive && ((Main.player[Main.npc[NPC.plantBoss].target].position.Y < Main.worldSurface * 16.0 || Main.player[Main.npc[NPC.plantBoss].target].position.Y > ((Main.maxTilesY - 200) * 16)) | despawn)) { npc.localAI[0] -= 4f; enrage = true; @@ -8576,9 +8598,9 @@ namespace CalamityMod.NPCs if (Main.netMode == NetmodeID.MultiplayerClient) { if (npc.ai[0] == 0f) - npc.ai[0] = (float)(int)(npc.Center.X / 16f); + npc.ai[0] = (int)(npc.Center.X / 16f); if (npc.ai[1] == 0f) - npc.ai[1] = (float)(int)(npc.Center.X / 16f); + npc.ai[1] = (int)(npc.Center.X / 16f); } // Find new spot to move to after set time has passed @@ -8600,7 +8622,7 @@ namespace CalamityMod.NPCs for (int num763 = 0; num763 < Main.maxNPCs; num763++) { if (num763 != npc.whoAmI && Main.npc[num763].active && Main.npc[num763].type == npc.type && (Main.npc[num763].velocity.X != 0f || Main.npc[num763].velocity.Y != 0f)) - npc.localAI[0] = (float)Main.rand.Next(60, 301); + npc.localAI[0] = Main.rand.Next(60, 301); } } @@ -8608,7 +8630,7 @@ namespace CalamityMod.NPCs if (npc.localAI[0] <= 0f) { // Reset timer - npc.localAI[0] = (float)Main.rand.Next(300, 601); + npc.localAI[0] = Main.rand.Next(300, 601); // Pick location bool flag50 = false; @@ -8633,7 +8655,7 @@ namespace CalamityMod.NPCs } int num767 = 20; - num767 += (int)(100f * ((float)num764 / 1000f)); + num767 += (int)(100f * (num764 / 1000f)); int num768 = num765 + Main.rand.Next(-num767, num767 + 1); int num769 = num766 + Main.rand.Next(-num767, num767 + 1); @@ -8642,8 +8664,8 @@ namespace CalamityMod.NPCs if (WorldGen.SolidTile(num768, num769) || (Main.tile[num768, num769].wall > 0 && (num764 > 500 || lifeRatio < 0.5f))) { flag50 = true; - npc.ai[0] = (float)num768; - npc.ai[1] = (float)num769; + npc.ai[0] = num768; + npc.ai[1] = num769; npc.netUpdate = true; } } catch @@ -8668,7 +8690,7 @@ namespace CalamityMod.NPCs Vector2 vector95 = new Vector2(npc.Center.X, npc.Center.Y); float num773 = npc.ai[0] * 16f - 8f - vector95.X; float num774 = npc.ai[1] * 16f - 8f - vector95.Y; - float num775 = (float)Math.Sqrt((double)(num773 * num773 + num774 * num774)); + float num775 = (float)Math.Sqrt(num773 * num773 + num774 * num774); if (num775 < 12f + velocity) { npc.velocity.X = num773; @@ -8685,12 +8707,12 @@ namespace CalamityMod.NPCs Vector2 vector96 = new Vector2(npc.Center.X, npc.Center.Y); float num776 = Main.npc[NPC.plantBoss].Center.X - vector96.X; float num777 = Main.npc[NPC.plantBoss].Center.Y - vector96.Y; - npc.rotation = (float)Math.Atan2((double)num777, (double)num776) - 1.57f; + npc.rotation = (float)Math.Atan2(num777, num776) - MathHelper.PiOver2; } return false; } - public static bool BuffedPlanterasTentacleAI(NPC npc, Mod mod) + public static bool BuffedPlanterasTentacleAI(NPC npc, Mod mod, bool chaos) { bool death = CalamityWorld.death || CalamityWorld.bossRushActive; @@ -8713,9 +8735,9 @@ namespace CalamityMod.NPCs npc.localAI[0] -= 1f; if (npc.localAI[0] <= 0f) { - npc.localAI[0] = (float)Main.rand.Next(120, 480); - npc.ai[0] = (float)Main.rand.Next(-100, 101); - npc.ai[1] = (float)Main.rand.Next(-100, 101); + npc.localAI[0] = Main.rand.Next(120, 480); + npc.ai[0] = Main.rand.Next(-100, 101); + npc.ai[1] = Main.rand.Next(-100, 101); npc.netUpdate = true; } } @@ -8725,7 +8747,7 @@ namespace CalamityMod.NPCs // Velocity and acceleration float num779 = CalamityWorld.bossRushActive ? 1f : 0.5f; - float num781 = death ? 1f : 1f - (float)npc.life / (float)npc.lifeMax; + float num781 = death ? 1f : 1f - npc.life / (float)npc.lifeMax; float num780 = (CalamityWorld.bossRushActive ? 300f : 200f) + (num781 * 50f); // Despawn if Plantera is gone @@ -8736,14 +8758,14 @@ namespace CalamityMod.NPCs } // Movement - float num782 = Main.npc[num778].position.X + (float)(Main.npc[num778].width / 2); - float num783 = Main.npc[num778].position.Y + (float)(Main.npc[num778].height / 2); + float num782 = Main.npc[num778].position.X + (Main.npc[num778].width / 2); + float num783 = Main.npc[num778].position.Y + (Main.npc[num778].height / 2); Vector2 vector97 = new Vector2(num782, num783); float num784 = num782 + npc.ai[0]; float num785 = num783 + npc.ai[1]; float num786 = num784 - vector97.X; float num787 = num785 - vector97.Y; - float num788 = (float)Math.Sqrt((double)(num786 * num786 + num787 * num787)); + float num788 = (float)Math.Sqrt(num786 * num786 + num787 * num787); num788 = num780 / num788; num786 *= num788; num787 *= num788; @@ -8784,25 +8806,25 @@ namespace CalamityMod.NPCs if (num786 > 0f) { npc.spriteDirection = 1; - npc.rotation = (float)Math.Atan2((double)num787, (double)num786); + npc.rotation = (float)Math.Atan2(num787, num786); } if (num786 < 0f) { npc.spriteDirection = -1; - npc.rotation = (float)Math.Atan2((double)num787, (double)num786) + 3.14f; + npc.rotation = (float)Math.Atan2(num787, num786) + MathHelper.Pi; } return false; } #endregion #region Buffed Golem AI - public static bool BuffedGolemAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedGolemAI(NPC npc, bool enraged, Mod mod, bool chaos) { // whoAmI variable NPC.golemBoss = npc.whoAmI; // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; // Phases bool death = CalamityWorld.death || CalamityWorld.bossRushActive; @@ -8829,7 +8851,7 @@ namespace CalamityMod.NPCs // Enrage if the target isn't inside the temple bool enrage = true; - if ((double)Main.player[npc.target].Center.Y > Main.worldSurface * 16.0) + if (Main.player[npc.target].Center.Y > Main.worldSurface * 16.0) { int num = (int)Main.player[npc.target].Center.X / 16; int num2 = (int)Main.player[npc.target].Center.Y / 16; @@ -8859,7 +8881,7 @@ namespace CalamityMod.NPCs // Damage if (!flag40) - npc.damage = (int)((float)npc.defDamage * 1.5f); + npc.damage = (int)(npc.defDamage * 1.5f); // Phase 2, check for free head bool flag43 = NPC.AnyNPCs(NPCID.GolemHeadFree); @@ -8871,8 +8893,8 @@ namespace CalamityMod.NPCs Dust dust = Main.dust[num642]; dust.alpha += Main.rand.Next(100); dust.velocity *= 0.2f; - dust.velocity.Y -= 0.5f + (float)Main.rand.Next(10) * 0.1f; - dust.fadeIn = 0.5f + (float)Main.rand.Next(10) * 0.1f; + dust.velocity.Y -= 0.5f + Main.rand.Next(10) * 0.1f; + dust.fadeIn = 0.5f + Main.rand.Next(10) * 0.1f; if (Main.rand.Next(10) == 0) { @@ -8881,7 +8903,7 @@ namespace CalamityMod.NPCs { Main.dust[num642].noGravity = true; dust = Main.dust[num642]; - dust.scale *= 1f + (float)Main.rand.Next(10) * 0.1f; + dust.scale *= 1f + Main.rand.Next(10) * 0.1f; dust.velocity.Y -= 1f; } } @@ -8892,8 +8914,8 @@ namespace CalamityMod.NPCs Dust dust = Main.dust[num643]; dust.alpha += Main.rand.Next(100); dust.velocity *= 0.2f; - dust.velocity.Y -= 0.5f + (float)Main.rand.Next(10) * 0.1f; - dust.fadeIn = 0.5f + (float)Main.rand.Next(10) * 0.1f; + dust.velocity.Y -= 0.5f + Main.rand.Next(10) * 0.1f; + dust.fadeIn = 0.5f + Main.rand.Next(10) * 0.1f; if (Main.rand.Next(10) == 0) { @@ -8902,7 +8924,7 @@ namespace CalamityMod.NPCs { Main.dust[num643].noGravity = true; dust = Main.dust[num643]; - dust.scale *= 1f + (float)Main.rand.Next(10) * 0.1f; + dust.scale *= 1f + Main.rand.Next(10) * 0.1f; dust.velocity.Y -= 1f; } } @@ -8932,9 +8954,9 @@ namespace CalamityMod.NPCs if (npc.localAI[1] % divisor == 0f && (Vector2.Distance(Main.player[npc.target].Center, vector82) > 160f || !flag43)) { float num673 = enrage ? 12f : 6f; - float num674 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector82.X; - float num675 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector82.Y; - float num676 = (float)Math.Sqrt((double)(num674 * num674 + num675 * num675)); + float num674 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector82.X; + float num675 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector82.Y; + float num676 = (float)Math.Sqrt(num674 * num674 + num675 * num675); num676 = num673 / num676; num674 *= num676; @@ -8992,9 +9014,9 @@ namespace CalamityMod.NPCs if (enrage) velocityX *= 1.5f; - npc.velocity.X = velocityX * (float)npc.direction; + npc.velocity.X = velocityX * npc.direction; - if (Main.player[npc.target].position.Y < npc.position.Y + (float)npc.height) + if (Main.player[npc.target].position.Y < npc.position.Y + npc.height) npc.velocity.Y = (!flag43 && !flag40) ? -15.1f : -12.1f; else npc.velocity.Y = 1f; @@ -9022,11 +9044,11 @@ namespace CalamityMod.NPCs { for (int num645 = 0; num645 < 4; num645++) { - int num646 = Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y + (float)npc.height), npc.width + 20, 4, 31, 0f, 0f, 100, default, 1.5f); + int num646 = Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y + npc.height), npc.width + 20, 4, 31, 0f, 0f, 100, default, 1.5f); Dust dust = Main.dust[num646]; dust.velocity *= 0.2f; } - int num647 = Gore.NewGore(new Vector2((float)(num644 - 20), npc.position.Y + (float)npc.height - 8f), default, Main.rand.Next(61, 64), 1f); + int num647 = Gore.NewGore(new Vector2(num644 - 20, npc.position.Y + npc.height - 8f), default, Main.rand.Next(61, 64), 1f); Gore gore = Main.gore[num647]; gore.velocity *= 0.4f; } @@ -9042,7 +9064,7 @@ namespace CalamityMod.NPCs if (Main.rand.Next(2) == 0) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 20; num623++) @@ -9054,11 +9076,11 @@ namespace CalamityMod.NPCs Main.dust[num624].velocity.X *= 2f; } - int spawnX = (int)(npc.width / 2); + int spawnX = npc.width / 2; for (int i = 0; i < 5; i++) { - float velocityX = Main.rand.NextBool() ? (float)Main.rand.Next(4, 6) : (float)Main.rand.Next(-5, -3); - float velocityY = (float)Main.rand.Next(-1, 2); + float velocityX = Main.rand.NextBool() ? Main.rand.Next(4, 6) : Main.rand.Next(-5, -3); + float velocityY = Main.rand.Next(-1, 2); if (enrage) { @@ -9070,7 +9092,7 @@ namespace CalamityMod.NPCs if (death) damage += 3; - int proj = Projectile.NewProjectile(npc.Center.X + (float)Main.rand.Next(-spawnX, spawnX), npc.Center.Y + (float)(npc.height / 2) * 0.8f, + int proj = Projectile.NewProjectile(npc.Center.X + Main.rand.Next(-spawnX, spawnX), npc.Center.Y + (npc.height / 2) * 0.8f, velocityX, velocityY, ProjectileID.Fireball, damage, 0f, Main.myPlayer, 0f, 0f); Main.projectile[proj].timeLeft = 240; } @@ -9082,17 +9104,17 @@ namespace CalamityMod.NPCs // Fall through if (npc.target >= 0 && - ((Main.player[npc.target].position.Y > npc.position.Y + (float)npc.height && npc.velocity.Y > 0f) || (Main.player[npc.target].position.Y < npc.position.Y + (float)npc.height && npc.velocity.Y < 0f))) + ((Main.player[npc.target].position.Y > npc.position.Y + npc.height && npc.velocity.Y > 0f) || (Main.player[npc.target].position.Y < npc.position.Y + npc.height && npc.velocity.Y < 0f))) npc.noTileCollide = true; else npc.noTileCollide = false; // Velocity when falling - if (npc.position.X < Main.player[npc.target].position.X && npc.position.X + (float)npc.width > Main.player[npc.target].position.X + (float)Main.player[npc.target].width) + if (npc.position.X < Main.player[npc.target].position.X && npc.position.X + npc.width > Main.player[npc.target].position.X + Main.player[npc.target].width) { npc.velocity.X *= 0.9f; - if (Main.player[npc.target].position.Y > npc.position.Y + (float)npc.height) + if (Main.player[npc.target].position.Y > npc.position.Y + npc.height) { float fallSpeedBoost = death ? 0.8f : 0.8f * (1f - lifeRatio); float fallSpeed = 0.2f + fallSpeedBoost; @@ -9128,11 +9150,11 @@ namespace CalamityMod.NPCs // Despawn int num649 = CalamityWorld.bossRushActive ? 4500 : 3000; - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > (float)num649) + if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > num649) { npc.TargetClosest(true); - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > (float)num649) + if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > num649) npc.active = false; } @@ -9142,7 +9164,7 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedGolemHeadAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedGolemHeadAI(NPC npc, bool enraged, Mod mod, bool chaos) { // Don't collide npc.noTileCollide = true; @@ -9155,7 +9177,7 @@ namespace CalamityMod.NPCs } // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; bool death = CalamityWorld.death || CalamityWorld.bossRushActive; @@ -9171,7 +9193,7 @@ namespace CalamityMod.NPCs float num652 = Main.npc[NPC.golemBoss].Center.Y - vector80.Y; num652 -= 57f; num651 -= 3f; - float num653 = (float)Math.Sqrt((double)(num651 * num651 + num652 * num652)); + float num653 = (float)Math.Sqrt(num651 * num651 + num652 * num652); if (num653 < 20f) { npc.rotation = 0f; @@ -9188,7 +9210,7 @@ namespace CalamityMod.NPCs // Enrage if the target isn't inside the temple bool enrage = true; - if ((double)Main.player[npc.target].Center.Y > Main.worldSurface * 16.0) + if (Main.player[npc.target].Center.Y > Main.worldSurface * 16.0) { int num = (int)Main.player[npc.target].Center.X / 16; int num2 = (int)Main.player[npc.target].Center.Y / 16; @@ -9215,12 +9237,12 @@ namespace CalamityMod.NPCs { npc.ai[1] += 1f; int num654 = 180; - if (npc.ai[1] < 20f || npc.ai[1] > (float)(num654 - 20)) + if (npc.ai[1] < 20f || npc.ai[1] > (num654 - 20)) npc.localAI[0] = 1f; else npc.localAI[0] = 0f; - if (npc.ai[1] >= (float)num654) + if (npc.ai[1] >= num654) { npc.TargetClosest(true); @@ -9228,9 +9250,9 @@ namespace CalamityMod.NPCs Vector2 vector81 = new Vector2(npc.Center.X, npc.Center.Y + 10f); float num655 = enrage ? 16f : 8f; - float num656 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector81.X; - float num657 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector81.Y; - float num658 = (float)Math.Sqrt((double)(num656 * num656 + num657 * num657)); + float num656 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector81.X; + float num657 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector81.Y; + float num658 = (float)Math.Sqrt(num656 * num656 + num657 * num657); num658 = num655 / num658; num656 *= num658; @@ -9252,12 +9274,12 @@ namespace CalamityMod.NPCs // Fire projectiles from eye positions Vector2 vector82 = new Vector2(npc.Center.X, npc.Center.Y + 10f); - if (Main.player[npc.target].Center.X < npc.Center.X - (float)npc.width) + if (Main.player[npc.target].Center.X < npc.Center.X - npc.width) { npc.localAI[1] = -1f; vector82.X -= 40f; } - else if (Main.player[npc.target].Center.X > npc.Center.X + (float)npc.width) + else if (Main.player[npc.target].Center.X > npc.Center.X + npc.width) { npc.localAI[1] = 1f; vector82.X += 40f; @@ -9270,21 +9292,21 @@ namespace CalamityMod.NPCs npc.ai[1] += 1f + shootBoost; int num662 = 240; - if (npc.ai[1] < 20f || npc.ai[1] > (float)(num662 - 20)) + if (npc.ai[1] < 20f || npc.ai[1] > (num662 - 20)) npc.localAI[0] = 1f; else npc.localAI[0] = 0f; - if (npc.ai[1] >= (float)num662) + if (npc.ai[1] >= num662) { npc.TargetClosest(true); npc.ai[1] = 0f; float num663 = enrage ? 18f : 12f; - float num664 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector82.X; - float num665 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector82.Y; - float num666 = (float)Math.Sqrt((double)(num664 * num664 + num665 * num665)); + float num664 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector82.X; + float num665 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector82.Y; + float num666 = (float)Math.Sqrt(num664 * num664 + num665 * num665); num666 = num663 / num666; num664 *= num666; @@ -9329,9 +9351,9 @@ namespace CalamityMod.NPCs if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) num673 = 14f; - float num674 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector82.X; - float num675 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector82.Y; - float num676 = (float)Math.Sqrt((double)(num674 * num674 + num675 * num675)); + float num674 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector82.X; + float num675 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector82.Y; + float num676 = (float)Math.Sqrt(num674 * num674 + num675 * num675); num676 = num673 / num676; num674 *= num676; @@ -9358,9 +9380,9 @@ namespace CalamityMod.NPCs if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) num678 = 14f; - float num679 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector82.X; - float num680 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector82.Y; - float num681 = (float)Math.Sqrt((double)(num679 * num679 + num680 * num680)); + float num679 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector82.X; + float num680 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector82.Y; + float num681 = (float)Math.Sqrt(num679 * num679 + num680 * num680); num681 = num678 / num681; num679 *= num681; @@ -9391,7 +9413,7 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedGolemHeadFreeAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedGolemHeadFreeAI(NPC npc, bool enraged, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); @@ -9403,8 +9425,8 @@ namespace CalamityMod.NPCs } // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; - float golemLifeRatio = (float)Main.npc[NPC.golemBoss].life / (float)Main.npc[NPC.golemBoss].lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; + float golemLifeRatio = Main.npc[NPC.golemBoss].life / (float)Main.npc[NPC.golemBoss].lifeMax; float combinedRatio = lifeRatio + golemLifeRatio; // Phases @@ -9425,7 +9447,7 @@ namespace CalamityMod.NPCs // Enrage if the target isn't inside the temple bool enrage = true; - if ((double)Main.player[npc.target].Center.Y > Main.worldSurface * 16.0) + if (Main.player[npc.target].Center.Y > Main.worldSurface * 16.0) { int num = (int)Main.player[npc.target].Center.X / 16; int num2 = (int)Main.player[npc.target].Center.Y / 16; @@ -9526,7 +9548,7 @@ namespace CalamityMod.NPCs Vector2 vector87 = new Vector2(npc.Center.X, npc.Center.Y); float num702 = Main.player[npc.target].Center.X - vector87.X + offsetX; float num703 = Main.player[npc.target].Center.Y - vector87.Y + offsetY; - float num704 = (float)Math.Sqrt((double)(num702 * num702 + num703 * num703)); + float num704 = (float)Math.Sqrt(num702 * num702 + num703 * num703); // Static movement if (phase3) @@ -9604,7 +9626,7 @@ namespace CalamityMod.NPCs npc.ai[1] += 1f + shootBoost; int num705 = 360; - if (npc.ai[1] < 20f || npc.ai[1] > (float)(num705 - 20)) + if (npc.ai[1] < 20f || npc.ai[1] > (num705 - 20)) npc.localAI[0] = 1f; else npc.localAI[0] = 0f; @@ -9612,15 +9634,15 @@ namespace CalamityMod.NPCs if (flag44 && !phase3) npc.ai[1] = 20f; - if (npc.ai[1] >= (float)num705 && Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 160f) + if (npc.ai[1] >= num705 && Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 160f) { npc.ai[1] = 0f; Vector2 vector88 = new Vector2(npc.Center.X, npc.Center.Y - 10f); float num706 = enrage ? 10f : 5f; - float num709 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector88.X; - float num710 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector88.Y; - float num711 = (float)Math.Sqrt((double)(num709 * num709 + num710 * num710)); + float num709 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector88.X; + float num710 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector88.Y; + float num711 = (float)Math.Sqrt(num709 * num709 + num710 * num710); num711 = num706 / num711; num709 *= num711; @@ -9662,9 +9684,9 @@ namespace CalamityMod.NPCs vector89.X += 14f; float num714 = 5f + shootBoost; - float num717 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector89.X; - float num718 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector89.Y; - float num719 = (float)Math.Sqrt((double)(num717 * num717 + num718 * num718)); + float num717 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector89.X; + float num718 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector89.Y; + float num719 = (float)Math.Sqrt(num717 * num717 + num718 * num718); num719 = num714 / num719; num717 *= num719; @@ -9694,14 +9716,14 @@ namespace CalamityMod.NPCs #endregion #region Buffed Duke Fishron AI - public static bool BuffedDukeFishronAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedDukeFishronAI(NPC npc, bool enraged, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); // Variables bool death = CalamityWorld.death || CalamityWorld.bossRushActive; - bool phase2 = (double)npc.life <= (double)npc.lifeMax * 0.66 || death; - bool phase3 = (double)npc.life <= (double)npc.lifeMax * (death ? 0.33 : 0.2); + bool phase2 = npc.life <= npc.lifeMax * 0.66 || death; + bool phase3 = npc.life <= npc.lifeMax * (death ? 0.33 : 0.2); bool phase2AI = npc.ai[0] > 4f; bool phase3AI = npc.ai[0] > 9f; bool charging = npc.ai[3] < 10f; @@ -9709,18 +9731,18 @@ namespace CalamityMod.NPCs // Adjust stats if (phase3AI) { - npc.damage = (int)((float)npc.defDamage * 1.32f); - npc.defense = (int)((float)npc.defDefense * 0.75f); + npc.damage = (int)(npc.defDamage * 1.32f); + npc.defense = (int)(npc.defDefense * 0.75f); } else if (phase2AI) { - npc.damage = (int)((float)npc.defDamage * 1.44f); + npc.damage = (int)(npc.defDamage * 1.44f); npc.defense = npc.defDefense; } else { npc.damage = npc.defDamage; - npc.defense = (int)((float)npc.defDefense * 1.2f); + npc.defense = (int)(npc.defDefense * 1.2f); } int num2 = 30; @@ -9780,7 +9802,7 @@ namespace CalamityMod.NPCs int num14 = 4; float scaleFactor3 = 6f; float scaleFactor4 = 20f; - float num15 = 6.28318548f / (float)(num13 / 2); + float num15 = MathHelper.TwoPi / (num13 / 2); int num16 = 75; Vector2 vector = npc.Center; Player player = Main.player[npc.target]; @@ -9811,8 +9833,8 @@ namespace CalamityMod.NPCs // Enrage variable bool enrage = !CalamityWorld.bossRushActive && - (player.position.Y < 800f || (double)player.position.Y > Main.worldSurface * 16.0 || - (player.position.X > 6400f && player.position.X < (float)(Main.maxTilesX * 16 - 6400))); + (player.position.Y < 800f || player.position.Y > Main.worldSurface * 16.0 || + (player.position.X > 6400f && player.position.X < (Main.maxTilesX * 16 - 6400))); // If the player isn't in the ocean biome or Fishron is transitioning between phases, become immune if (!phase3AI) @@ -9837,7 +9859,7 @@ namespace CalamityMod.NPCs calamityGlobalNPC.newAI[0] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 1f, (float)(npc.target + 1)); + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 1f, npc.target + 1); npc.netUpdate = true; } @@ -9857,13 +9879,13 @@ namespace CalamityMod.NPCs } // Rotation - float num17 = (float)Math.Atan2((double)(player.Center.Y - vector.Y), (double)(player.Center.X - vector.X)); + float num17 = (float)Math.Atan2(player.Center.Y - vector.Y, player.Center.X - vector.X); if (npc.spriteDirection == 1) - num17 += 3.14159274f; + num17 += MathHelper.Pi; if (num17 < 0f) - num17 += 6.28318548f; - if (num17 > 6.28318548f) - num17 -= 6.28318548f; + num17 += MathHelper.TwoPi; + if (num17 > MathHelper.TwoPi) + num17 -= MathHelper.TwoPi; if (npc.ai[0] == -1f) num17 = 0f; if (npc.ai[0] == 3f) @@ -9887,14 +9909,14 @@ namespace CalamityMod.NPCs if (npc.rotation < num17) { - if ((double)(num17 - npc.rotation) > 3.1415926535897931) + if ((num17 - npc.rotation) > MathHelper.Pi) npc.rotation -= num18; else npc.rotation += num18; } if (npc.rotation > num17) { - if ((double)(npc.rotation - num17) > 3.1415926535897931) + if ((npc.rotation - num17) > MathHelper.Pi) npc.rotation += num18; else npc.rotation -= num18; @@ -9903,9 +9925,9 @@ namespace CalamityMod.NPCs if (npc.rotation > num17 - num18 && npc.rotation < num17 + num18) npc.rotation = num17; 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 > num17 - num18 && npc.rotation < num17 + num18) npc.rotation = num17; @@ -9952,12 +9974,12 @@ namespace CalamityMod.NPCs } // Spawn dust and play sound - if (npc.ai[2] == (float)(num9 - 30)) + if (npc.ai[2] == num9 - 30) { int num20 = 36; for (int i = 0; i < num20; i++) { - Vector2 dust = (Vector2.Normalize(npc.velocity) * new Vector2((float)npc.width / 2f, (float)npc.height) * 0.75f * 0.5f).RotatedBy((double)((float)(i - (num20 / 2 - 1)) * 6.28318548f / (float)num20), default) + npc.Center; + Vector2 dust = (Vector2.Normalize(npc.velocity) * new Vector2(npc.width / 2f, (float)npc.height) * 0.75f * 0.5f).RotatedBy((i - (num20 / 2 - 1)) * MathHelper.TwoPi / num20, default) + npc.Center; Vector2 vector2 = dust - npc.Center; int num21 = Dust.NewDust(dust + vector2, 0, 0, 172, vector2.X * 2f, vector2.Y * 2f, 100, default, 1.4f); Main.dust[num21].noGravity = true; @@ -9969,7 +9991,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num16) + if (npc.ai[2] >= num16) { npc.ai[0] = 0f; npc.ai[1] = 0f; @@ -9983,7 +10005,7 @@ namespace CalamityMod.NPCs { // Velocity if (npc.ai[1] == 0f) - npc.ai[1] = (float)(300 * Math.Sign((vector - player.Center).X)); + npc.ai[1] = 300 * Math.Sign((vector - player.Center).X); Vector2 vector3 = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - vector - npc.velocity) * scaleFactor; if (npc.velocity.X < vector3.X) @@ -10016,19 +10038,19 @@ namespace CalamityMod.NPCs if (num22 != 0) { if (npc.ai[2] == 0f && num22 != npc.direction) - npc.rotation += 3.14159274f; + npc.rotation += MathHelper.Pi; npc.direction = num22; if (npc.spriteDirection != -npc.direction) - npc.rotation += 3.14159274f; + npc.rotation += MathHelper.Pi; npc.spriteDirection = -npc.direction; } // Phase switch npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num2) + if (npc.ai[2] >= num2) { int num23 = 0; switch ((int)npc.ai[3]) @@ -10067,7 +10089,7 @@ namespace CalamityMod.NPCs // Velocity npc.velocity = Vector2.Normalize(player.Center - vector) * chargeVelocity; - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction if (num22 != 0) @@ -10075,7 +10097,7 @@ namespace CalamityMod.NPCs npc.direction = num22; if (npc.spriteDirection == 1) - npc.rotation += 3.14159274f; + npc.rotation += MathHelper.Pi; npc.spriteDirection = -npc.direction; } @@ -10119,8 +10141,8 @@ namespace CalamityMod.NPCs int num24 = 7; 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)) * 3.1415926535897931 / (double)(float)num24, default) + vector; - Vector2 vector4 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + Vector2 arg_E1C_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((j - (num24 / 2 - 1)) * MathHelper.Pi / num24, default) + vector; + Vector2 vector4 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); int num25 = Dust.NewDust(arg_E1C_0 + vector4, 0, 0, 172, vector4.X * 2f, vector4.Y * 2f, 100, default, 1.4f); Main.dust[num25].noGravity = true; Main.dust[num25].noLight = true; @@ -10144,7 +10166,7 @@ namespace CalamityMod.NPCs { // Velocity if (npc.ai[1] == 0f) - npc.ai[1] = (float)(300 * Math.Sign((vector - player.Center).X)); + npc.ai[1] = 300 * Math.Sign((vector - player.Center).X); Vector2 vector5 = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - vector - npc.velocity) * scaleFactor2; if (npc.velocity.X < vector5.X) @@ -10176,13 +10198,13 @@ namespace CalamityMod.NPCs if (npc.ai[2] == 0f) Main.PlaySound(29, (int)vector.X, (int)vector.Y, 20, 1f, 0f); - if (npc.ai[2] % (float)num7 == 0f) + if (npc.ai[2] % num7 == 0f) { Main.PlaySound(4, (int)npc.Center.X, (int)npc.Center.Y, 19, 1f, 0f); if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector6 = Vector2.Normalize(player.Center - vector) * (float)(npc.width + 20) / 2f + vector; + Vector2 vector6 = Vector2.Normalize(player.Center - vector) * (npc.width + 20) / 2f + vector; NPC.NewNPC((int)vector6.X, (int)vector6.Y + 45, NPCID.DetonatingBubble, 0, 0f, 0f, 0f, 0f, 255); } } @@ -10193,12 +10215,12 @@ namespace CalamityMod.NPCs { npc.direction = num26; if (npc.spriteDirection != -npc.direction) - npc.rotation += 3.14159274f; + npc.rotation += MathHelper.Pi; npc.spriteDirection = -npc.direction; } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num6) + if (npc.ai[2] >= num6) { npc.ai[0] = 0f; npc.ai[1] = 0f; @@ -10218,15 +10240,15 @@ namespace CalamityMod.NPCs if (npc.ai[2] == (float)(num9 - 30)) Main.PlaySound(29, (int)vector.X, (int)vector.Y, 9, 1f, 0f); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == (float)(num9 - 30)) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == num9 - 30) { - Vector2 vector7 = npc.rotation.ToRotationVector2() * (Vector2.UnitX * (float)npc.direction) * (float)(npc.width + 20) / 2f + vector; + Vector2 vector7 = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + vector; bool normal = Main.rand.NextBool(); float velocityY = normal ? 8f : -4f; float ai1 = normal ? 0f : -1f; - Projectile.NewProjectile(vector7.X, vector7.Y, (float)(npc.direction * 3), velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); - Projectile.NewProjectile(vector7.X, vector7.Y, (float)(-(float)npc.direction * 3), velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); + Projectile.NewProjectile(vector7.X, vector7.Y, npc.direction * 3, velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); + Projectile.NewProjectile(vector7.X, vector7.Y, -(float)npc.direction * 3, velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); velocityY = normal ? -4f : 8f; ai1 = normal ? -1f : 0f; @@ -10234,7 +10256,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num9) + if (npc.ai[2] >= num9) { npc.ai[0] = 0f; npc.ai[1] = 0f; @@ -10251,11 +10273,11 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Sound - if (npc.ai[2] == (float)(num10 - 60)) + if (npc.ai[2] == num10 - 60) Main.PlaySound(29, (int)vector.X, (int)vector.Y, 20, 1f, 0f); npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num10) + if (npc.ai[2] >= num10) { npc.ai[0] = 5f; npc.ai[1] = 0f; @@ -10270,7 +10292,7 @@ namespace CalamityMod.NPCs { // Velocity if (npc.ai[1] == 0f) - npc.ai[1] = (float)(300 * Math.Sign((vector - player.Center).X)); + npc.ai[1] = 300 * Math.Sign((vector - player.Center).X); Vector2 vector8 = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - vector - npc.velocity) * scaleFactor; if (npc.velocity.X < vector8.X) @@ -10303,19 +10325,19 @@ namespace CalamityMod.NPCs if (num27 != 0) { if (npc.ai[2] == 0f && num27 != npc.direction) - npc.rotation += 3.14159274f; + npc.rotation += MathHelper.Pi; npc.direction = num27; if (npc.spriteDirection != -npc.direction) - npc.rotation += 3.14159274f; + npc.rotation += MathHelper.Pi; npc.spriteDirection = -npc.direction; } // Phase switch npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num2) + if (npc.ai[2] >= num2) { int num28 = 0; switch ((int)npc.ai[3]) @@ -10350,7 +10372,7 @@ namespace CalamityMod.NPCs // Velocity and rotation npc.velocity = Vector2.Normalize(player.Center - vector) * chargeVelocity; - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction if (num27 != 0) @@ -10358,7 +10380,7 @@ namespace CalamityMod.NPCs npc.direction = num27; if (npc.spriteDirection == 1) - npc.rotation += 3.14159274f; + npc.rotation += MathHelper.Pi; npc.spriteDirection = -npc.direction; } @@ -10369,7 +10391,7 @@ namespace CalamityMod.NPCs { // Velocity and rotation npc.velocity = Vector2.Normalize(player.Center - vector) * scaleFactor4; - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction if (num27 != 0) @@ -10377,7 +10399,7 @@ namespace CalamityMod.NPCs npc.direction = num27; if (npc.spriteDirection == 1) - npc.rotation += 3.14159274f; + npc.rotation += MathHelper.Pi; npc.spriteDirection = -npc.direction; } @@ -10417,8 +10439,8 @@ namespace CalamityMod.NPCs int num29 = 7; 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)) * 3.1415926535897931 / (double)(float)num29, default) + vector; - Vector2 vector9 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + Vector2 arg_1A97_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((k - (num29 / 2 - 1)) * MathHelper.Pi / num29, default) + vector; + Vector2 vector9 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); int num30 = Dust.NewDust(arg_1A97_0 + vector9, 0, 0, 172, vector9.X * 2f, vector9.Y * 2f, 100, default, 1.4f); Main.dust[num30].noGravity = true; Main.dust[num30].noLight = true; @@ -10427,7 +10449,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)chargeTime) + if (npc.ai[2] >= chargeTime) { npc.ai[0] = 5f; npc.ai[1] = 0f; @@ -10444,20 +10466,20 @@ namespace CalamityMod.NPCs if (npc.ai[2] == 0f) Main.PlaySound(29, (int)vector.X, (int)vector.Y, 20, 1f, 0f); - if (npc.ai[2] % (float)num14 == 0f) + if (npc.ai[2] % num14 == 0f) { Main.PlaySound(4, (int)npc.Center.X, (int)npc.Center.Y, 19, 1f, 0f); if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector10 = Vector2.Normalize(npc.velocity) * (float)(npc.width + 20) / 2f + vector; + Vector2 vector10 = Vector2.Normalize(npc.velocity) * (npc.width + 20) / 2f + vector; int num31 = NPC.NewNPC((int)vector10.X, (int)vector10.Y + 45, NPCID.DetonatingBubble, 0, 0f, 0f, 0f, 0f, 255); Main.npc[num31].target = npc.target; - Main.npc[num31].velocity = Vector2.Normalize(npc.velocity).RotatedBy((double)(1.57079637f * (float)npc.direction), default) * scaleFactor3; + Main.npc[num31].velocity = Vector2.Normalize(npc.velocity).RotatedBy(MathHelper.PiOver2 * npc.direction, default) * scaleFactor3; Main.npc[num31].netUpdate = true; - Main.npc[num31].ai[3] = (float)Main.rand.Next(80, 121) / 100f; + Main.npc[num31].ai[3] = Main.rand.Next(80, 121) / 100f; - if (npc.ai[2] % (float)(num14 * 5) == 0f) + if (npc.ai[2] % (num14 * 5) == 0f) { int npc2 = NPC.NewNPC((int)vector10.X, (int)vector10.Y + 45, NPCID.Sharkron2, 0, 0f, 0f, 0f, 0f, 255); Main.npc[npc2].ai[1] = 89f; @@ -10466,11 +10488,11 @@ namespace CalamityMod.NPCs } // Velocity and rotation - npc.velocity = npc.velocity.RotatedBy((double)(-(double)num15 * (float)npc.direction), default); - npc.rotation -= num15 * (float)npc.direction; + npc.velocity = npc.velocity.RotatedBy(-(double)num15 * (float)npc.direction, default); + npc.rotation -= num15 * npc.direction; npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num13) + if (npc.ai[2] >= num13) { npc.ai[0] = 5f; npc.ai[1] = 0f; @@ -10487,14 +10509,14 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Play sound and spawn cthulhunado - if (npc.ai[2] == (float)(num9 - 30)) + if (npc.ai[2] == num9 - 30) Main.PlaySound(29, (int)vector.X, (int)vector.Y, 20, 1f, 0f); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == (float)(num9 - 30)) - Projectile.NewProjectile(vector.X, vector.Y, 0f, 0f, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 1f, (float)(npc.target + 1)); + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == num9 - 30) + Projectile.NewProjectile(vector.X, vector.Y, 0f, 0f, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 1f, npc.target + 1); npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num9) + if (npc.ai[2] >= num9) { npc.ai[0] = 5f; npc.ai[1] = 0f; @@ -10507,7 +10529,7 @@ namespace CalamityMod.NPCs else if (npc.ai[0] == 9f) { // Alpha adjustments - if (npc.ai[2] < (float)(num11 - 90)) + if (npc.ai[2] < num11 - 90) { if (Collision.SolidCollision(npc.position, npc.width, npc.height)) npc.alpha += 15; @@ -10531,11 +10553,11 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Play sound - if (npc.ai[2] == (float)(num11 - 60)) + if (npc.ai[2] == num11 - 60) Main.PlaySound(29, (int)vector.X, (int)vector.Y, 20, 1f, 0f); npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num11) + if (npc.ai[2] >= num11) { npc.ai[0] = 10f; npc.ai[1] = 0f; @@ -10561,7 +10583,7 @@ namespace CalamityMod.NPCs // Teleport location if (npc.ai[1] == 0f) - npc.ai[1] = (float)(360 * Math.Sign((vector - player.Center).X)); + npc.ai[1] = 360 * Math.Sign((vector - player.Center).X); Vector2 desiredVelocity = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - vector - npc.velocity) * scaleFactor; npc.SimpleFlyMovement(desiredVelocity, num3); @@ -10572,7 +10594,7 @@ namespace CalamityMod.NPCs { if (npc.ai[2] == 0f && num32 != npc.direction) { - npc.rotation += 3.14159274f; + npc.rotation += MathHelper.Pi; for (int l = 0; l < npc.oldPos.Length; l++) npc.oldPos[l] = Vector2.Zero; } @@ -10580,14 +10602,14 @@ namespace CalamityMod.NPCs npc.direction = num32; if (npc.spriteDirection != -npc.direction) - npc.rotation += 3.14159274f; + npc.rotation += MathHelper.Pi; npc.spriteDirection = -npc.direction; } // Phase switch npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num2) + if (npc.ai[2] >= num2) { int num33 = 0; switch ((int)npc.ai[3]) @@ -10616,7 +10638,7 @@ namespace CalamityMod.NPCs // Velocity and rotation npc.velocity = Vector2.Normalize(player.Center - vector) * chargeVelocity; - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X); + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); // Direction if (num32 != 0) @@ -10624,7 +10646,7 @@ namespace CalamityMod.NPCs npc.direction = num32; if (npc.spriteDirection == 1) - npc.rotation += 3.14159274f; + npc.rotation += MathHelper.Pi; npc.spriteDirection = -npc.direction; } @@ -10660,8 +10682,8 @@ namespace CalamityMod.NPCs int num34 = 7; 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)) * 3.1415926535897931 / (double)(float)num34, default) + vector; - Vector2 vector11 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + Vector2 arg_2444_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((m - (num34 / 2 - 1)) * MathHelper.Pi / num34, default) + vector; + Vector2 vector11 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); int num35 = Dust.NewDust(arg_2444_0 + vector11, 0, 0, 172, vector11.X * 2f, vector11.Y * 2f, 100, default, 1.4f); Main.dust[num35].noGravity = true; Main.dust[num35].noLight = true; @@ -10670,7 +10692,7 @@ namespace CalamityMod.NPCs } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)chargeTime) + if (npc.ai[2] >= chargeTime) { npc.ai[0] = 10f; npc.ai[1] = 0f; @@ -10699,14 +10721,14 @@ namespace CalamityMod.NPCs npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); // Play sound - if (npc.ai[2] == (float)(num12 / 2)) + if (npc.ai[2] == num12 / 2) Main.PlaySound(29, (int)vector.X, (int)vector.Y, 20, 1f, 0f); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == (float)(num12 / 2)) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == num12 / 2) { // Teleport location if (npc.ai[1] == 0f) - npc.ai[1] = (float)(300 * Math.Sign((vector - player.Center).X)); + npc.ai[1] = 300 * Math.Sign((vector - player.Center).X); // Rotation and direction Vector2 center = player.Center + new Vector2(-npc.ai[1], -200f); @@ -10716,7 +10738,7 @@ namespace CalamityMod.NPCs { if (npc.ai[2] == 0f && num36 != npc.direction) { - npc.rotation += 3.14159274f; + npc.rotation += MathHelper.Pi; for (int n = 0; n < npc.oldPos.Length; n++) npc.oldPos[n] = Vector2.Zero; } @@ -10724,14 +10746,14 @@ namespace CalamityMod.NPCs npc.direction = num36; if (npc.spriteDirection != -npc.direction) - npc.rotation += 3.14159274f; + npc.rotation += MathHelper.Pi; npc.spriteDirection = -npc.direction; } } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num12) + if (npc.ai[2] >= num12) { npc.ai[0] = 10f; npc.ai[1] = 0f; @@ -10753,7 +10775,7 @@ namespace CalamityMod.NPCs #endregion #region Buffed Cultist AI - public static bool BuffedCultistAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedCultistAI(NPC npc, bool enraged, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); @@ -10767,7 +10789,7 @@ namespace CalamityMod.NPCs } // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; // Phases bool death = CalamityWorld.death || CalamityWorld.bossRushActive; @@ -10906,7 +10928,7 @@ namespace CalamityMod.NPCs new List().Add(npc.whoAmI); for (int j = 0; j < Main.maxNPCs; j++) { - if (Main.npc[j].active && Main.npc[j].type == 440 && Main.npc[j].ai[3] == (float)npc.whoAmI) + if (Main.npc[j].active && Main.npc[j].type == 440 && Main.npc[j].ai[3] == npc.whoAmI) { Main.npc[j].life = 0; Main.npc[j].HitEffect(0, 10.0); @@ -10990,7 +11012,7 @@ namespace CalamityMod.NPCs npc.direction = npc.spriteDirection = num14; } npc.ai[1] += 1f; - if (npc.ai[1] >= (float)idleTime & isCultist) + if (npc.ai[1] >= idleTime & isCultist) { int num15 = 0; if (phase2) @@ -11106,7 +11128,7 @@ namespace CalamityMod.NPCs if (num15 == 0) { // Set a location to move to - float num16 = (float)Math.Ceiling((double)((player.Center + new Vector2(0f, -100f) - center).Length() / 50f)); + float num16 = (float)Math.Ceiling((player.Center + new Vector2(0f, -100f) - center).Length() / 50f); if (num16 == 0f) { num16 = 1f; @@ -11118,7 +11140,7 @@ namespace CalamityMod.NPCs list2.Add(npc.whoAmI); for (int k = 0; k < Main.maxNPCs; k++) { - if (Main.npc[k].active && Main.npc[k].type == NPCID.CultistBossClone && Main.npc[k].ai[3] == (float)npc.whoAmI) + if (Main.npc[k].active && Main.npc[k].type == NPCID.CultistBossClone && Main.npc[k].ai[3] == npc.whoAmI) { list2.Add(k); } @@ -11130,7 +11152,7 @@ namespace CalamityMod.NPCs { NPC nPC2 = Main.npc[current2]; Vector2 center2 = nPC2.Center; - float num18 = (float)((num17 + flag5.ToInt() + 1) / 2) * 6.28318548f * 0.4f / (float)list2.Count; + float num18 = (num17 + flag5.ToInt() + 1) / 2 * MathHelper.TwoPi * 0.4f / list2.Count; if (num17 % 2 == 1) { num18 *= -1f; @@ -11139,7 +11161,7 @@ namespace CalamityMod.NPCs { num18 = 0f; } - Vector2 value = new Vector2(0f, -1f).RotatedBy((double)num18, default) * new Vector2(150f, 200f); + Vector2 value = new Vector2(0f, -1f).RotatedBy(num18, default) * new Vector2(150f, 200f); Vector2 value2 = player.Center + value - center2; nPC2.ai[0] = 1f; nPC2.ai[1] = num16; @@ -11215,7 +11237,7 @@ namespace CalamityMod.NPCs Vector2 vec = Vector2.Normalize(player.Center - center); if (vec.HasNaNs()) { - vec = new Vector2((float)npc.direction, 0f); + vec = new Vector2(npc.direction, 0f); } if ((npc.ai[1] >= 4f & isCultist) && (int)(npc.ai[1] - 4f) % iceMistFireRate == 0) { @@ -11224,7 +11246,7 @@ namespace CalamityMod.NPCs List list3 = new List(); for (int l = 0; l < Main.maxNPCs; l++) { - if (Main.npc[l].active && Main.npc[l].type == NPCID.CultistBossClone && Main.npc[l].ai[3] == (float)npc.whoAmI) + if (Main.npc[l].active && Main.npc[l].type == NPCID.CultistBossClone && Main.npc[l].ai[3] == npc.whoAmI) { list3.Add(l); } @@ -11241,9 +11263,9 @@ namespace CalamityMod.NPCs vec = Vector2.Normalize(player.Center - center3 + player.velocity * 20f); if (vec.HasNaNs()) { - vec = new Vector2((float)npc.direction, 0f); + vec = new Vector2(npc.direction, 0f); } - Vector2 vector = center3 + new Vector2((float)(npc.direction * 30), 12f); + Vector2 vector = center3 + new Vector2(npc.direction * 30, 12f); Vector2 vector2 = vec * (fireballSpeed + (float)Main.rand.NextDouble() * 2f); vector2 = vector2.RotatedByRandom(0.52359879016876221); Projectile.NewProjectile(vector.X, vector.Y, vector2.X, vector2.Y, ProjectileID.CultistBossFireBallClone, fireballDamage, 0f, Main.myPlayer, 0f, 0f); @@ -11254,15 +11276,15 @@ namespace CalamityMod.NPCs vec = Vector2.Normalize(player.Center - center + player.velocity * 20f); if (vec.HasNaNs()) { - vec = new Vector2((float)npc.direction, 0f); + vec = new Vector2(npc.direction, 0f); } - Vector2 vector3 = npc.Center + new Vector2((float)(npc.direction * 30), 12f); + Vector2 vector3 = npc.Center + new Vector2(npc.direction * 30, 12f); Vector2 vector4 = vec * iceMistSpeed; Projectile.NewProjectile(vector3.X, vector3.Y, vector4.X, vector4.Y, ProjectileID.CultistBossIceMist, iceMistDamage, 0f, Main.myPlayer, 0f, 1f); } } npc.ai[1] += 1f; - if (npc.ai[1] >= (float)(4 + iceMistFireRate * 2)) + if (npc.ai[1] >= (4 + iceMistFireRate * 2)) { npc.ai[0] = 0f; npc.ai[1] = 0f; @@ -11279,7 +11301,7 @@ namespace CalamityMod.NPCs Vector2 vec2 = Vector2.Normalize(player.Center - center); if (vec2.HasNaNs()) { - vec2 = new Vector2((float)npc.direction, 0f); + vec2 = new Vector2(npc.direction, 0f); } if ((npc.ai[1] >= 4f & isCultist) && (int)(npc.ai[1] - 4f) % fireballFireRate == 0) { @@ -11288,7 +11310,7 @@ namespace CalamityMod.NPCs List list4 = new List(); for (int num20 = 0; num20 < Main.maxNPCs; num20++) { - if (Main.npc[num20].active && Main.npc[num20].type == NPCID.CultistBossClone && Main.npc[num20].ai[3] == (float)npc.whoAmI) + if (Main.npc[num20].active && Main.npc[num20].type == NPCID.CultistBossClone && Main.npc[num20].ai[3] == npc.whoAmI) { list4.Add(num20); } @@ -11307,9 +11329,9 @@ namespace CalamityMod.NPCs vec2 = Vector2.Normalize(player.Center - center4 + player.velocity * 20f); if (vec2.HasNaNs()) { - vec2 = new Vector2((float)npc.direction, 0f); + vec2 = new Vector2(npc.direction, 0f); } - Vector2 vector5 = center4 + new Vector2((float)(npc.direction * 30), 12f); + Vector2 vector5 = center4 + new Vector2(npc.direction * 30, 12f); Vector2 vector6 = vec2 * (fireballSpeed + (float)Main.rand.NextDouble() * 2f); vector6 = vector6.RotatedByRandom(0.52359879016876221); Projectile.NewProjectile(vector5.X, vector5.Y, vector6.X, vector6.Y, ProjectileID.CultistBossFireBallClone, fireballDamage, 0f, Main.myPlayer, 0f, 0f); @@ -11326,16 +11348,16 @@ namespace CalamityMod.NPCs vec2 = Vector2.Normalize(player.Center - center + player.velocity * 20f); if (vec2.HasNaNs()) { - vec2 = new Vector2((float)npc.direction, 0f); + vec2 = new Vector2(npc.direction, 0f); } - Vector2 vector7 = npc.Center + new Vector2((float)(npc.direction * 30), 12f); + Vector2 vector7 = npc.Center + new Vector2(npc.direction * 30, 12f); Vector2 vector8 = vec2 * (fireballSpeed + (float)Main.rand.NextDouble() * 4f); vector8 = vector8.RotatedByRandom(0.52359879016876221); Projectile.NewProjectile(vector7.X, vector7.Y, vector8.X, vector8.Y, ProjectileID.CultistBossFireBall, fireballDamage, 0f, Main.myPlayer, 0f, 0f); } } npc.ai[1] += 1f; - if (npc.ai[1] >= (float)(4 + fireballFireRate * 4)) + if (npc.ai[1] >= (4 + fireballFireRate * 4)) { npc.ai[0] = 0f; npc.ai[1] = 0f; @@ -11361,7 +11383,7 @@ namespace CalamityMod.NPCs List list5 = new List(); for (int num25 = 0; num25 < Main.maxNPCs; num25++) { - if (Main.npc[num25].active && Main.npc[num25].type == NPCID.CultistBossClone && Main.npc[num25].ai[3] == (float)npc.whoAmI) + if (Main.npc[num25].active && Main.npc[num25].type == NPCID.CultistBossClone && Main.npc[num25].ai[3] == npc.whoAmI) { list5.Add(num25); } @@ -11378,9 +11400,9 @@ namespace CalamityMod.NPCs Vector2 vec3 = Vector2.Normalize(player.Center - center5 + player.velocity * 20f); if (vec3.HasNaNs()) { - vec3 = new Vector2((float)npc.direction, 0f); + vec3 = new Vector2(npc.direction, 0f); } - Vector2 vector9 = center5 + new Vector2((float)(npc.direction * 30), 12f); + Vector2 vector9 = center5 + new Vector2(npc.direction * 30, 12f); Vector2 vector10 = vec3 * (fireballSpeed + (float)Main.rand.NextDouble() * 2f); vector10 = vector10.RotatedByRandom(0.52359879016876221); Projectile.NewProjectile(vector9.X, vector9.Y, vector10.X, vector10.Y, ProjectileID.CultistBossFireBallClone, fireballDamage, 0f, Main.myPlayer, 0f, 0f); @@ -11388,7 +11410,7 @@ namespace CalamityMod.NPCs Projectile.NewProjectile(npc.Center.X, npc.Center.Y - 100f, 0f, 0f, ProjectileID.CultistBossLightningOrb, lightningDamage, 0f, Main.myPlayer, 0f, 0f); } npc.ai[1] += 1f; - if (npc.ai[1] >= (float)(20 + lightningOrbFireRate)) + if (npc.ai[1] >= (20 + lightningOrbFireRate)) { npc.ai[0] = 0f; npc.ai[1] = 0f; @@ -11404,7 +11426,7 @@ namespace CalamityMod.NPCs npc.localAI[2] = 10f; if (Vector2.Normalize(player.Center - center).HasNaNs()) { - new Vector2((float)npc.direction, 0f); + new Vector2(npc.direction, 0f); } if (npc.ai[1] >= 0f && npc.ai[1] < 30f) { @@ -11421,7 +11443,7 @@ namespace CalamityMod.NPCs List list6 = new List(); for (int num29 = 0; num29 < Main.maxNPCs; num29++) { - if (Main.npc[num29].active && Main.npc[num29].type == NPCID.CultistBossClone && Main.npc[num29].ai[3] == (float)npc.whoAmI) + if (Main.npc[num29].active && Main.npc[num29].type == NPCID.CultistBossClone && Main.npc[num29].ai[3] == npc.whoAmI) { list6.Add(num29); } @@ -11435,7 +11457,7 @@ namespace CalamityMod.NPCs float[] array = new float[num31]; for (int num32 = 0; num32 < array.Length; num32++) { - array[num32] = Vector2.Distance(npc.Center + spinningpoint.RotatedBy((double)((float)num32 * 6.28318548f / (float)num31 - 1.57079637f), default), player.Center); + array[num32] = Vector2.Distance(npc.Center + spinningpoint.RotatedBy(num32 * MathHelper.TwoPi / num31 - MathHelper.PiOver2, default), player.Center); } int num33 = 0; for (int num34 = 1; num34 < array.Length; num34++) @@ -11458,11 +11480,11 @@ namespace CalamityMod.NPCs { if (num33 != num36) { - Vector2 vector11 = npc.Center + spinningpoint.RotatedBy((double)((float)num36 * 6.28318548f / (float)num31 - 1.57079637f), default); + Vector2 vector11 = npc.Center + spinningpoint.RotatedBy(num36 * MathHelper.TwoPi / num31 - MathHelper.PiOver2, default); if (num35-- > 0) { int num37 = NPC.NewNPC((int)vector11.X, (int)vector11.Y + npc.height / 2, NPCID.CultistBossClone, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num37].ai[3] = (float)npc.whoAmI; + Main.npc[num37].ai[3] = npc.whoAmI; Main.npc[num37].netUpdate = true; Main.npc[num37].localAI[1] = npc.localAI[1]; } @@ -11474,8 +11496,8 @@ namespace CalamityMod.NPCs } } } - npc.ai[2] = (float)Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, ProjectileID.CultistRitual, 0, 0f, Main.myPlayer, 0f, (float)npc.whoAmI); - npc.Center += spinningpoint.RotatedBy((double)((float)num33 * 6.28318548f / (float)num31 - 1.57079637f), default); + npc.ai[2] = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, ProjectileID.CultistRitual, 0, 0f, Main.myPlayer, 0f, npc.whoAmI); + npc.Center += spinningpoint.RotatedBy(num33 * MathHelper.TwoPi / num31 - MathHelper.PiOver2, default); npc.netUpdate = true; list6.Clear(); } @@ -11616,7 +11638,7 @@ namespace CalamityMod.NPCs { npc.localAI[2] = 13f; npc.ai[1] += 1f; - if (npc.ai[1] >= (float)(idleTime * 3)) + if (npc.ai[1] >= (idleTime * 3)) { npc.ai[0] = 0f; npc.ai[1] = 0f; @@ -11633,7 +11655,7 @@ namespace CalamityMod.NPCs Vector2 vec4 = Vector2.Normalize(player.Center - center); if (vec4.HasNaNs()) { - vec4 = new Vector2((float)npc.direction, 0f); + vec4 = new Vector2(npc.direction, 0f); } if ((npc.ai[1] >= 4f & isCultist) && (int)(npc.ai[1] - 4f) % ancientLightSpawnRate == 0) { @@ -11642,7 +11664,7 @@ namespace CalamityMod.NPCs List list7 = new List(); for (int num44 = 0; num44 < Main.maxNPCs; num44++) { - if (Main.npc[num44].active && Main.npc[num44].type == NPCID.CultistBossClone && Main.npc[num44].ai[3] == (float)npc.whoAmI) + if (Main.npc[num44].active && Main.npc[num44].type == NPCID.CultistBossClone && Main.npc[num44].ai[3] == npc.whoAmI) { list7.Add(num44); } @@ -11661,11 +11683,11 @@ namespace CalamityMod.NPCs vec4 = Vector2.Normalize(player.Center - center6 + player.velocity * 20f); if (vec4.HasNaNs()) { - vec4 = new Vector2((float)npc.direction, 0f); + vec4 = new Vector2(npc.direction, 0f); } - Vector2 vector16 = center6 + new Vector2((float)(npc.direction * 30), 12f); + Vector2 vector16 = center6 + new Vector2(npc.direction * 30, 12f); int num46 = 0; - while ((float)num46 < 5f) + while (num46 < 5f) { Vector2 vector17 = vec4 * (fireballSpeed + (float)Main.rand.NextDouble() * 2f); vector17 = vector17.RotatedByRandom(1.2566370964050293); @@ -11685,20 +11707,20 @@ namespace CalamityMod.NPCs vec4 = Vector2.Normalize(player.Center - center + player.velocity * 20f); if (vec4.HasNaNs()) { - vec4 = new Vector2((float)npc.direction, 0f); + vec4 = new Vector2(npc.direction, 0f); } - Vector2 vector18 = npc.Center + new Vector2((float)(npc.direction * 30), 12f); + Vector2 vector18 = npc.Center + new Vector2(npc.direction * 30, 12f); float scaleFactor = 10f; if (CalamityWorld.bossRushActive) scaleFactor *= 1.5f; float num48 = 0.251327425f; int num49 = 0; - while ((float)num49 < 5f) + while (num49 < 5f) { Vector2 vector19 = vec4 * scaleFactor; - vector19 = vector19.RotatedBy((double)(num48 * (float)num49 - (1.2566371f - num48) / 2f), default); - float ai = (Main.rand.NextFloat() - 0.5f) * 0.3f * 6.28318548f / 60f; + vector19 = vector19.RotatedBy(num48 * num49 - (1.2566371f - num48) / 2f, default); + float ai = (Main.rand.NextFloat() - 0.5f) * 0.3f * MathHelper.TwoPi / 60f; int num50 = NPC.NewNPC((int)vector18.X, (int)vector18.Y + 7, NPCID.AncientLight, 0, 0f, ai, vector19.X, vector19.Y, 255); Main.npc[num50].velocity = vector19; num49++; @@ -11706,7 +11728,7 @@ namespace CalamityMod.NPCs } } npc.ai[1] += 1f; - if (npc.ai[1] >= (float)(4 + ancientLightSpawnRate * 2)) + if (npc.ai[1] >= (4 + ancientLightSpawnRate * 2)) { npc.ai[0] = 0f; npc.ai[1] = 0f; @@ -11725,7 +11747,7 @@ namespace CalamityMod.NPCs List list8 = new List(); for (int num51 = 0; num51 < Main.maxNPCs; num51++) { - if (Main.npc[num51].active && Main.npc[num51].type == NPCID.CultistBossClone && Main.npc[num51].ai[3] == (float)npc.whoAmI) + if (Main.npc[num51].active && Main.npc[num51].type == NPCID.CultistBossClone && Main.npc[num51].ai[3] == npc.whoAmI) { list8.Add(num51); } @@ -11771,7 +11793,7 @@ namespace CalamityMod.NPCs } if (flag7) { - NPC.NewNPC(num60 * 16 + 8, num61 * 16 + 8, NPCID.AncientDoom, 0, (float)npc.whoAmI, 0f, 0f, 0f, 255); + NPC.NewNPC(num60 * 16 + 8, num61 * 16 + 8, NPCID.AncientDoom, 0, npc.whoAmI, 0f, 0f, 0f, 255); break; } } @@ -11806,7 +11828,7 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedAncientLightAI(NPC npc, Mod mod) + public static bool BuffedAncientLightAI(NPC npc, Mod mod, bool chaos) { bool death = CalamityWorld.death || CalamityWorld.bossRushActive; @@ -11831,7 +11853,7 @@ namespace CalamityMod.NPCs return false; } - npc.rotation = npc.velocity.ToRotation() - 1.57079637f; + npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; if (npc.localAI[0] == 0f) { @@ -11840,7 +11862,7 @@ namespace CalamityMod.NPCs npc.velocity.Y = npc.ai[3]; for (int num1492 = 0; num1492 < 13; num1492++) { - int num1493 = Dust.NewDust(npc.position, npc.width, npc.height, 261, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 2.5f); + int num1493 = Dust.NewDust(npc.position, npc.width, npc.height, 261, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 2.5f); Main.dust[num1493].noGravity = true; Main.dust[num1493].fadeIn = 1f; Dust dust = Main.dust[num1493]; @@ -11853,7 +11875,7 @@ namespace CalamityMod.NPCs { if (Main.rand.Next(10 - (int)Math.Min(7f, npc.velocity.Length())) < 1) { - int num1495 = Dust.NewDust(npc.position, npc.width, npc.height, 261, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 2.5f); + int num1495 = Dust.NewDust(npc.position, npc.width, npc.height, 261, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 2.5f); Main.dust[num1495].noGravity = true; Dust dust = Main.dust[num1495]; dust.velocity *= 0.2f; @@ -11871,14 +11893,14 @@ namespace CalamityMod.NPCs } } - npc.dontTakeDamage = (npc.ai[0] >= 0f && npc.ai[0] <= 180f); + npc.dontTakeDamage = npc.ai[0] >= 0f && npc.ai[0] <= 180f; if (npc.ai[0] >= 0f) { npc.ai[0] += 1f; if (npc.ai[0] > 60f) { - npc.velocity = npc.velocity.RotatedBy((double)npc.ai[1], default(Vector2)); + npc.velocity = npc.velocity.RotatedBy(npc.ai[1], default); } if (npc.ai[0] > 120f) { @@ -11893,7 +11915,7 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedAncientDoomAI(NPC npc, Mod mod) + public static bool BuffedAncientDoomAI(NPC npc, Mod mod, bool chaos) { bool death = CalamityWorld.death || CalamityWorld.bossRushActive; npc.damage = npc.defDamage = 0; @@ -11922,7 +11944,7 @@ namespace CalamityMod.NPCs { flag110 = true; } - npc.ai[1] += (float)num1498; + npc.ai[1] += num1498; float num1500 = npc.ai[1] / num1497; num1500 = MathHelper.Clamp(num1500, 0f, 1f); npc.position = npc.Center; @@ -11931,27 +11953,27 @@ namespace CalamityMod.NPCs npc.alpha = (int)(255f - num1500 * 255f); if (Main.rand.NextBool(6)) { - Vector2 spinningpoint4 = Vector2.UnitY.RotatedByRandom(6.2831854820251465); + Vector2 spinningpoint4 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); Dust dust17 = Main.dust[Dust.NewDust(npc.Center - spinningpoint4 * 20f, 0, 0, 27, 0f, 0f, 0, default, 1f)]; dust17.noGravity = true; - dust17.position = npc.Center - spinningpoint4 * (float)Main.rand.Next(10, 21) * npc.scale; - dust17.velocity = spinningpoint4.RotatedBy(1.5707963705062866, default) * 4f; + dust17.position = npc.Center - spinningpoint4 * Main.rand.Next(10, 21) * npc.scale; + dust17.velocity = spinningpoint4.RotatedBy(MathHelper.PiOver2, default) * 4f; dust17.scale = 0.5f + Main.rand.NextFloat(); dust17.fadeIn = 0.5f; } if (Main.rand.NextBool(6)) { - Vector2 spinningpoint5 = Vector2.UnitY.RotatedByRandom(6.2831854820251465); + Vector2 spinningpoint5 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); Dust dust18 = Main.dust[Dust.NewDust(npc.Center - spinningpoint5 * 30f, 0, 0, 240, 0f, 0f, 0, default, 1f)]; dust18.noGravity = true; dust18.position = npc.Center - spinningpoint5 * 20f * npc.scale; - dust18.velocity = spinningpoint5.RotatedBy(-1.5707963705062866, default) * 2f; + dust18.velocity = spinningpoint5.RotatedBy(-MathHelper.PiOver2, default) * 2f; dust18.scale = 0.5f + Main.rand.NextFloat(); dust18.fadeIn = 0.5f; } if (Main.rand.NextBool(6)) { - Vector2 vector254 = Vector2.UnitY.RotatedByRandom(6.2831854820251465); + Vector2 vector254 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); Dust dust19 = Main.dust[Dust.NewDust(npc.Center - vector254 * 30f, 0, 0, 240, 0f, 0f, 0, default, 1f)]; dust19.position = npc.Center - vector254 * 20f * npc.scale; dust19.velocity = Vector2.Zero; @@ -11960,7 +11982,7 @@ namespace CalamityMod.NPCs dust19.noLight = true; } npc.localAI[0] += 0.05235988f; - npc.localAI[1] = 0.25f + Vector2.UnitY.RotatedBy((double)(npc.ai[1] * 6.28318548f / 60f), default).Y * 0.25f; + npc.localAI[1] = 0.25f + Vector2.UnitY.RotatedBy(npc.ai[1] * MathHelper.TwoPi / 60f, default).Y * 0.25f; if (npc.ai[1] >= num1496) { int damage = 50; @@ -11972,7 +11994,7 @@ namespace CalamityMod.NPCs { for (int num1501 = 0; num1501 < 4; num1501++) { - Vector2 vector255 = new Vector2(0f, -num1499).RotatedBy((double)(1.57079637f * (float)num1501), default); + Vector2 vector255 = new Vector2(0f, -num1499).RotatedBy(MathHelper.PiOver2 * num1501, default); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector255.X, vector255.Y, ProjectileID.AncientDoomProjectile, damage, 0f, Main.myPlayer, 0f, 0f); } } @@ -11988,7 +12010,7 @@ namespace CalamityMod.NPCs #endregion #region Buffed Moon Lord AI - public static bool BuffedMoonLordAI(NPC npc, bool enraged, Mod mod) + public static bool BuffedMoonLordAI(NPC npc, bool enraged, Mod mod, bool chaos) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); @@ -12046,7 +12068,7 @@ namespace CalamityMod.NPCs npc.ai[0] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient && npc.type == NPCID.MoonLordCore) { - npc.ai[2] = (float)Main.rand.Next(3); + npc.ai[2] = Main.rand.Next(3); npc.ai[2] = 0f; npc.netUpdate = true; } @@ -12072,7 +12094,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient && npc.type == NPCID.MoonLordCore) { - npc.ai[2] = (float)Main.rand.Next(3); + npc.ai[2] = Main.rand.Next(3); npc.ai[2] = 0f; npc.netUpdate = true; @@ -12083,7 +12105,7 @@ namespace CalamityMod.NPCs for (int num1156 = 0; num1156 < 2; num1156 = num + 1) { int num1157 = NPC.NewNPC((int)npc.Center.X + num1156 * 800 - 400, (int)npc.Center.Y - 100, NPCID.MoonLordHand, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num1157].ai[2] = (float)num1156; + Main.npc[num1157].ai[2] = num1156; Main.npc[num1157].netUpdate = true; int[] arg_381A6_0 = array5; num = num1155; @@ -12101,12 +12123,12 @@ namespace CalamityMod.NPCs for (int num1159 = 0; num1159 < 3; num1159 = num + 1) { - Main.npc[array5[num1159]].ai[3] = (float)npc.whoAmI; + Main.npc[array5[num1159]].ai[3] = npc.whoAmI; num = num1159; } for (int num1160 = 0; num1160 < 3; num1160 = num + 1) { - npc.localAI[num1160] = (float)array5[num1160]; + npc.localAI[num1160] = array5[num1160]; num = num1160; } } @@ -12126,7 +12148,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { int num = NPC.NewNPC((int)Main.npc[(int)npc.localAI[2]].Center.X, (int)Main.npc[(int)npc.localAI[2]].Center.Y, NPCID.MoonLordFreeEye, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num].ai[3] = (float)npc.whoAmI; + Main.npc[num].ai[3] = npc.whoAmI; Main.npc[num].netUpdate = true; } } @@ -12244,7 +12266,7 @@ namespace CalamityMod.NPCs else if (npc.ai[0] == 2f) { npc.dontTakeDamage = true; - Vector2 value6 = new Vector2((float)npc.direction, -0.5f); + Vector2 value6 = new Vector2(npc.direction, -0.5f); npc.velocity = Vector2.Lerp(npc.velocity, value6, 0.98f); npc.ai[1] += 1f; @@ -12291,8 +12313,8 @@ namespace CalamityMod.NPCs flag86 = false; float num1163 = (float)Main.rand.Next(6, 19); - float num1164 = 6.28318548f / num1163; - float num1165 = 6.28318548f * Main.rand.NextFloat(); + float num1164 = MathHelper.TwoPi / num1163; + float num1165 = MathHelper.TwoPi * Main.rand.NextFloat(); float scaleFactor8 = 1f + Main.rand.NextFloat() * 2f; float num1166 = 1f + Main.rand.NextFloat(); float fadeIn = 0.4f + Main.rand.NextFloat(); @@ -12310,7 +12332,7 @@ namespace CalamityMod.NPCs Dust dust2 = Main.dust[Dust.NewDust(vector159, 0, 0, 229, 0f, 0f, 0, default, 1f)]; dust2.noGravity = true; dust2.position = vector159; - dust2.velocity = Vector2.UnitY.RotatedBy((double)(num1165 + num1164 * num1168), default) * scaleFactor8 * (Main.rand.NextFloat() * 1.6f + 1.6f); + dust2.velocity = Vector2.UnitY.RotatedBy(num1165 + num1164 * num1168, default) * scaleFactor8 * (Main.rand.NextFloat() * 1.6f + 1.6f); dust2.fadeIn = fadeIn; dust2.scale = num1166; ai1 = num1168; @@ -12365,8 +12387,8 @@ namespace CalamityMod.NPCs if (flag88) { - float num1170 = (float)(Main.rand.Next(4) < 2).ToDirectionInt() * (0.3926991f + 0.7853982f * Main.rand.NextFloat()); - Vector2 vector164 = new Vector2(0f, -Main.rand.NextFloat() * 0.5f - 0.5f).RotatedBy((double)num1170, default) * 6f; + float num1170 = (Main.rand.Next(4) < 2).ToDirectionInt() * (0.3926991f + MathHelper.PiOver4 * Main.rand.NextFloat()); + Vector2 vector164 = new Vector2(0f, -Main.rand.NextFloat() * 0.5f - 0.5f).RotatedBy(num1170, default) * 6f; Projectile.NewProjectile(vector163.X, vector163.Y, vector164.X, vector164.Y, ProjectileID.BlowupSmokeMoonlord, 0, 0f, Main.myPlayer, 0f, 0f); } } @@ -12409,7 +12431,7 @@ namespace CalamityMod.NPCs else if (npc.ai[0] == 3f) { npc.dontTakeDamage = true; - Vector2 value7 = new Vector2((float)npc.direction, -0.5f); + Vector2 value7 = new Vector2(npc.direction, -0.5f); npc.velocity = Vector2.Lerp(npc.velocity, value7, 0.98f); npc.ai[1] += 1f; @@ -12610,8 +12632,8 @@ namespace CalamityMod.NPCs while (num1214 < 5) { - num1208 = (float)NPC.MoonLordAttacksArray[num1212, num1213, 1, num1214]; - if (num1208 + (float)num1215 > npc.ai[1]) + num1208 = NPC.MoonLordAttacksArray[num1212, num1213, 1, num1214]; + if (num1208 + num1215 > npc.ai[1]) break; num1215 += (int)num1208; @@ -12623,12 +12645,12 @@ namespace CalamityMod.NPCs { num1214 = 0; npc.ai[1] = 0f; - num1208 = (float)NPC.MoonLordAttacksArray[num1212, num1213, 1, num1214]; + num1208 = NPC.MoonLordAttacksArray[num1212, num1213, 1, num1214]; num1215 = 0; } - npc.ai[0] = (float)NPC.MoonLordAttacksArray[num1212, num1213, 0, num1214]; - num1207 = (float)((int)npc.ai[1] - num1215); + npc.ai[0] = NPC.MoonLordAttacksArray[num1212, num1213, 0, num1214]; + num1207 = (int)npc.ai[1] - num1215; if (npc.ai[0] != num1211) npc.netUpdate = true; @@ -12698,9 +12720,9 @@ namespace CalamityMod.NPCs num1223 = 1.65f; } - Vector2 vector199 = center20 + ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * value19 / 2f; + Vector2 vector199 = center20 + ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * value19 / 2f; int num1224 = Dust.NewDust(vector199 - Vector2.One * 8f, 16, 16, num1222, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, default, 1f); - Main.dust[num1224].velocity = Vector2.Normalize(center20 - vector199) * 3.5f * (10f - (float)num1220 * 2f) / 10f; + Main.dust[num1224].velocity = Vector2.Normalize(center20 - vector199) * 3.5f * (10f - num1220 * 2f) / 10f; Main.dust[num1224].noGravity = true; Main.dust[num1224].scale = num1223; Main.dust[num1224].customData = npc; @@ -12760,9 +12782,9 @@ namespace CalamityMod.NPCs if (vector200.X < 0f) num1225 = 1f; - vector200 = vector200.RotatedBy((double)(-(double)num1225 * 6.28318548f / 6f), default); - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector200.X, vector200.Y, projectileType, damage, 0f, Main.myPlayer, num1225 * 6.28318548f / calamityGlobalNPC.newAI[1], (float)npc.whoAmI); - npc.ai[2] = (vector200.ToRotation() + 9.424778f) * num1225; + vector200 = vector200.RotatedBy(-(double)num1225 * MathHelper.TwoPi / 6f, default); + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector200.X, vector200.Y, projectileType, damage, 0f, Main.myPlayer, num1225 * MathHelper.TwoPi / calamityGlobalNPC.newAI[1], (float)npc.whoAmI); + npc.ai[2] = (vector200.ToRotation() + MathHelper.Pi + MathHelper.TwoPi) * num1225; npc.netUpdate = true; } @@ -12770,15 +12792,15 @@ namespace CalamityMod.NPCs if (npc.localAI[1] > 1f) npc.localAI[1] = 1f; - float num1226 = (float)(npc.ai[2] >= 0f).ToDirectionInt(); + float num1226 = (npc.ai[2] >= 0f).ToDirectionInt(); float num1227 = npc.ai[2]; if (num1227 < 0f) num1227 *= -1f; - num1227 += -9.424778f; - num1227 += num1226 * 6.28318548f / calamityGlobalNPC.newAI[1]; + num1227 += -(MathHelper.Pi + MathHelper.TwoPi); + num1227 += num1226 * MathHelper.TwoPi / calamityGlobalNPC.newAI[1]; npc.localAI[0] = num1227; - npc.ai[2] = (num1227 + 9.424778f) * num1226; + npc.ai[2] = (num1227 + MathHelper.Pi + MathHelper.TwoPi) * num1226; } else { @@ -12811,7 +12833,7 @@ namespace CalamityMod.NPCs if (vector202 != Vector2.Zero) vector202.Normalize(); - Projectile.NewProjectile(vector201.X, vector201.Y, vector202.X, vector202.Y, ProjectileID.MoonLeech, 0, 0f, Main.myPlayer, (float)(npc.whoAmI + 1), (float)num1228); + Projectile.NewProjectile(vector201.X, vector201.Y, vector202.X, vector202.Y, ProjectileID.MoonLeech, 0, 0f, Main.myPlayer, npc.whoAmI + 1, num1228); } } } @@ -12826,8 +12848,8 @@ namespace CalamityMod.NPCs Vector2 center21 = Main.player[npc.target].Center; int num1230 = NPC.NewNPC((int)center21.X, (int)center21.Y, NPCID.MoonLordLeechBlob, 0, 0f, 0f, 0f, 0f, 255); Main.npc[num1230].netUpdate = true; - Main.npc[num1230].ai[0] = (float)(npc.whoAmI + 1); - Main.npc[num1230].ai[1] = (float)num1229; + Main.npc[num1230].ai[0] = npc.whoAmI + 1; + Main.npc[num1230].ai[1] = num1229; } } } @@ -12907,9 +12929,9 @@ namespace CalamityMod.NPCs // Dictates whether this npc is vulnerable or not int num1231 = num1209 * 7; - if ((float)num1231 > npc.localAI[2]) + if (num1231 > npc.localAI[2]) npc.localAI[2] += 1f; - if ((float)num1231 < npc.localAI[2]) + if (num1231 < npc.localAI[2]) npc.localAI[2] -= 1f; if (npc.localAI[2] < 0f) npc.localAI[2] = 0f; @@ -12917,9 +12939,9 @@ namespace CalamityMod.NPCs npc.localAI[2] = 14f; int num1232 = num1210 * 5; - if ((float)num1232 > npc.localAI[3]) + if (num1232 > npc.localAI[3]) npc.localAI[3] += 1f; - if ((float)num1232 < npc.localAI[3]) + if (num1232 < npc.localAI[3]) npc.localAI[3] -= 1f; if (npc.localAI[3] < 0f) npc.localAI[2] = 0f; @@ -12941,7 +12963,7 @@ namespace CalamityMod.NPCs // Variables bool flag90 = npc.ai[2] == 0f; - float num1177 = (float)-(float)flag90.ToDirectionInt(); + float num1177 = -flag90.ToDirectionInt(); npc.spriteDirection = (int)num1177; npc.dontTakeDamage = npc.frameCounter >= 21.0; @@ -12979,8 +13001,8 @@ namespace CalamityMod.NPCs while (num1184 < 5) { - num1179 = (float)NPC.MoonLordAttacksArray[num1182, num1183, 1, num1184]; - if (num1179 + (float)num1185 > npc.ai[1]) + num1179 = NPC.MoonLordAttacksArray[num1182, num1183, 1, num1184]; + if (num1179 + num1185 > npc.ai[1]) break; num1185 += (int)num1179; @@ -12992,12 +13014,12 @@ namespace CalamityMod.NPCs { num1184 = 0; npc.ai[1] = 0f; - num1179 = (float)NPC.MoonLordAttacksArray[num1182, num1183, 1, num1184]; + num1179 = NPC.MoonLordAttacksArray[num1182, num1183, 1, num1184]; num1185 = 0; } - npc.ai[0] = (float)NPC.MoonLordAttacksArray[num1182, num1183, 0, num1184]; - num1178 = (float)((int)npc.ai[1] - num1185); + npc.ai[0] = NPC.MoonLordAttacksArray[num1182, num1183, 0, num1184]; + num1178 = (int)npc.ai[1] - num1185; if (npc.ai[0] != num1181) npc.netUpdate = true; } @@ -13080,20 +13102,20 @@ namespace CalamityMod.NPCs break; } - if (num1178 >= (float)(num1186 * num1187 * 2)) + if (num1178 >= (num1186 * num1187 * 2)) { npc.localAI[1] -= 0.07f; if (npc.localAI[1] < 0f) npc.localAI[1] = 0f; } - else if (num1178 >= (float)(num1186 * num1187)) + else if (num1178 >= (num1186 * num1187)) { npc.localAI[1] += 0.05f; if (npc.localAI[1] > 0.75f) npc.localAI[1] = 0.75f; - float num1188 = 6.28318548f * (num1178 % (float)(num1186 * num1187)) / (float)(num1186 * num1187) - 1.57079637f; - npc.localAI[0] = new Vector2((float)Math.Cos((double)num1188) * vector165.X, (float)Math.Sin((double)num1188) * vector165.Y).ToRotation(); + float num1188 = MathHelper.TwoPi * (num1178 % (num1186 * num1187)) / (num1186 * num1187) - MathHelper.PiOver2; + npc.localAI[0] = new Vector2((float)Math.Cos(num1188) * vector165.X, (float)Math.Sin(num1188) * vector165.Y).ToRotation(); int damage = 40; if (death) @@ -13124,7 +13146,7 @@ namespace CalamityMod.NPCs } Vector2 vector170 = Vector2.Normalize(vector168) * velocity; - float ai = (6.28318548f * (float)Main.rand.NextDouble() - 3.14159274f) / 30f + 0.0174532924f * num1177; + float ai = (MathHelper.TwoPi * (float)Main.rand.NextDouble() - MathHelper.Pi) / 30f + 0.0174532924f * num1177; Projectile.NewProjectile(vector169.X, vector169.Y, vector170.X, vector170.Y, ProjectileID.PhantasmalEye, damage, 0f, Main.myPlayer, 0f, ai); } } @@ -13134,8 +13156,8 @@ namespace CalamityMod.NPCs if (npc.localAI[1] > 0.75f) npc.localAI[1] = 0.75f; - float num1189 = 6.28318548f * (num1178 % (float)(num1186 * num1187)) / (float)(num1186 * num1187) - 1.57079637f; - npc.localAI[0] = new Vector2((float)Math.Cos((double)num1189) * vector165.X, (float)Math.Sin((double)num1189) * vector165.Y).ToRotation(); + float num1189 = MathHelper.TwoPi * (num1178 % (num1186 * num1187)) / (num1186 * num1187) - MathHelper.PiOver2; + npc.localAI[0] = new Vector2((float)Math.Cos(num1189) * vector165.X, (float)Math.Sin(num1189) * vector165.Y).ToRotation(); } } @@ -13229,10 +13251,10 @@ namespace CalamityMod.NPCs { Vector2 vector173 = new Vector2(5f * num1177, -8f); int num1191 = num1190 / 30; - vector173.X += ((float)num1191 - 3.5f) * num1177 * 3f; - vector173.Y += ((float)num1191 - 4.5f) * 1f; + vector173.X += (num1191 - 3.5f) * num1177 * 3f; + vector173.Y += (num1191 - 4.5f) * 1f; vector173 *= 1.2f; - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector173.X, vector173.Y, ProjectileID.PhantasmalSphere, damage, 1f, Main.myPlayer, 0f, (float)npc.whoAmI); + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector173.X, vector173.Y, ProjectileID.PhantasmalSphere, damage, 1f, Main.myPlayer, 0f, npc.whoAmI); } Vector2 vector174 = Vector2.SmoothStep(value12, value12 + value13, (num1178 - 30f) / 180f) - npc.Center; @@ -13283,7 +13305,7 @@ namespace CalamityMod.NPCs if (num1178 == 292f && Main.netMode != NetmodeID.MultiplayerClient) { - int num1193 = (int)Player.FindClosest(npc.position, npc.width, npc.height); + int num1193 = Player.FindClosest(npc.position, npc.width, npc.height); Vector2 vector176 = Vector2.Normalize(Main.player[num1193].Center - (npc.Center + Vector2.UnitY * -350f)); if (float.IsNaN(vector176.X) || float.IsNaN(vector176.Y)) vector176 = Vector2.UnitY; @@ -13310,7 +13332,7 @@ namespace CalamityMod.NPCs for (int num1194 = 0; num1194 < Main.maxProjectiles; num1194++) { Projectile projectile3 = Main.projectile[num1194]; - if (projectile3.active && projectile3.type == ProjectileID.PhantasmalSphere && projectile3.ai[1] == (float)npc.whoAmI && projectile3.ai[0] != -1f) + if (projectile3.active && projectile3.type == ProjectileID.PhantasmalSphere && projectile3.ai[1] == npc.whoAmI && projectile3.ai[0] != -1f) { projectile3.ai[0] = -1f; projectile3.velocity = vector176; @@ -13469,12 +13491,12 @@ namespace CalamityMod.NPCs // Frames int num1195 = num1180 * 7; - if ((double)num1195 > npc.frameCounter) + if (num1195 > npc.frameCounter) { double num1196 = npc.frameCounter; npc.frameCounter = num1196 + 1.0; } - if ((double)num1195 < npc.frameCounter) + if (num1195 < npc.frameCounter) { double num1196 = npc.frameCounter; npc.frameCounter = num1196 - 1.0; @@ -13541,8 +13563,8 @@ namespace CalamityMod.NPCs int num1244 = 0; while (num1243 < 10) { - num1241 = (float)NPC.MoonLordAttacksArray2[1, num1243]; - if (num1241 + (float)num1244 > npc.ai[1]) + num1241 = NPC.MoonLordAttacksArray2[1, num1243]; + if (num1241 + num1244 > npc.ai[1]) break; num1244 += (int)num1241; @@ -13553,12 +13575,12 @@ namespace CalamityMod.NPCs { num1243 = 0; npc.ai[1] = 0f; - num1241 = (float)NPC.MoonLordAttacksArray2[1, num1243]; + num1241 = NPC.MoonLordAttacksArray2[1, num1243]; num1244 = 0; } - npc.ai[0] = (float)NPC.MoonLordAttacksArray2[0, num1243]; - float num1245 = (float)((int)npc.ai[1] - num1244); + npc.ai[0] = NPC.MoonLordAttacksArray2[0, num1243]; + float num1245 = (int)npc.ai[1] - num1244; if (npc.ai[0] != num1242) npc.netUpdate = true; @@ -13576,9 +13598,9 @@ namespace CalamityMod.NPCs npc.localAI[0] = 0f; - npc.localAI[1] = (float)Math.Sin((double)(npc.ai[1] * 6.28318548f / 15f)) * 0.35f; + npc.localAI[1] = (float)Math.Sin(npc.ai[1] * MathHelper.TwoPi / 15f) * 0.35f; if (npc.localAI[1] < 0f) - npc.localAI[0] = 3.14159274f; + npc.localAI[0] = MathHelper.Pi; } else if (npc.ai[1] < 120f) { @@ -13615,15 +13637,24 @@ namespace CalamityMod.NPCs npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 1f, 0.2f); - float velocity = CalamityWorld.bossRushActive ? 38f : 30f; + float velocity = CalamityWorld.bossRushActive ? 42f : 36f; Vector2 center23 = npc.Center; - Vector2 center24 = Main.npc[(int)Main.npc[(int)npc.ai[3]].localAI[2]].Center; + Vector2 center24 = Main.player[npc.target].Center; Vector2 value24 = center24 - center23; value24 = Vector2.Normalize(value24) * velocity; - int num1246 = 30; - npc.velocity.X = (npc.velocity.X * (float)(num1246 - 1) + value24.X) / (float)num1246; - npc.velocity.Y = (npc.velocity.Y * (float)(num1246 - 1) + value24.Y) / (float)num1246; + if (Vector2.Distance(center23, center24) > 300f) + { + int num1246 = 30; + npc.velocity.X = (npc.velocity.X * (num1246 - 1) + value24.X) / num1246; + npc.velocity.Y = (npc.velocity.Y * (num1246 - 1) + value24.Y) / num1246; + } + else + { + npc.velocity *= 0.8f; + if (npc.velocity.Length() < 1f) + npc.velocity = Vector2.Zero; + } // Fly towards Moon Lord Head and stay away from other True Eyes float num1247 = 0.5f; @@ -13631,19 +13662,7 @@ namespace CalamityMod.NPCs { if (Main.npc[num1248].active) { - if (Main.npc[num1248].type == NPCID.MoonLordHead && Vector2.Distance(npc.Center, Main.npc[num1248].Center) > 600f) - { - if (npc.position.X < Main.npc[num1248].position.X) - npc.velocity.X = npc.velocity.X - num1247; - else - npc.velocity.X = npc.velocity.X + num1247; - - if (npc.position.Y < Main.npc[num1248].position.Y) - npc.velocity.Y = npc.velocity.Y - num1247; - else - npc.velocity.Y = npc.velocity.Y + num1247; - } - else if (num1248 != npc.whoAmI && Main.npc[num1248].type == npc.type) + if (num1248 != npc.whoAmI && Main.npc[num1248].type == npc.type) { if (Vector2.Distance(npc.Center, Main.npc[num1248].Center) < 150f) { @@ -13746,9 +13765,9 @@ namespace CalamityMod.NPCs } Vector2 spinningpoint2 = Vector2.UnitY * -30f; - Vector2 value25 = spinningpoint2.RotatedBy((double)((float)num1250 * 6.28318548f / 6f), default(Vector2)); - Vector2 value26 = spinningpoint2.RotatedBy((double)((float)num1251 * 6.28318548f / 6f), default(Vector2)); - Vector2 vector216 = Vector2.Lerp(value25, value26, num1249 - (float)((int)num1249)); + Vector2 value25 = spinningpoint2.RotatedBy(num1250 * MathHelper.TwoPi / 6f, default); + Vector2 value26 = spinningpoint2.RotatedBy(num1251 * MathHelper.TwoPi / 6f, default); + Vector2 vector216 = Vector2.Lerp(value25, value26, num1249 - (int)num1249); float value27 = vector216.Length() / 30f; npc.localAI[0] = vector216.ToRotation(); @@ -13756,7 +13775,7 @@ namespace CalamityMod.NPCs for (int num1252 = 0; num1252 < 2; num1252++) { - int num1253 = Dust.NewDust(npc.Center + vector216 - Vector2.One * 4f, 0, 0, 229, 0f, 0f, 0, default(Color), 1f); + int num1253 = Dust.NewDust(npc.Center + vector216 - Vector2.One * 4f, 0, 0, 229, 0f, 0f, 0, default, 1f); Dust dust = Main.dust[num1253]; dust.velocity += vector216 / 15f; Main.dust[num1253].noGravity = true; @@ -13776,7 +13795,7 @@ namespace CalamityMod.NPCs { if (num1245 < 105f) { - npc.localAI[0] = npc.localAI[0].AngleLerp(npc.ai[2] - 1.57079637f, 0.2f); + npc.localAI[0] = npc.localAI[0].AngleLerp(npc.ai[2] - MathHelper.PiOver2, 0.2f); npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 0.75f, 0.2f); @@ -13791,7 +13810,7 @@ namespace CalamityMod.NPCs for (int num1255 = 0; num1255 < Main.maxProjectiles; num1255++) { Projectile projectile7 = Main.projectile[num1255]; - if (projectile7.active && projectile7.type == ProjectileID.PhantasmalSphere && projectile7.ai[1] == (float)npc.whoAmI && projectile7.ai[0] != -1f) + if (projectile7.active && projectile7.type == ProjectileID.PhantasmalSphere && projectile7.ai[1] == npc.whoAmI && projectile7.ai[0] != -1f) { Projectile projectile8 = projectile7; projectile8.velocity += npc.velocity; @@ -13802,7 +13821,7 @@ namespace CalamityMod.NPCs npc.velocity.Y = npc.velocity.Y * 0.96f; - npc.ai[2] = (Main.player[npc.target].Center - npc.Center).ToRotation() + 1.57079637f; + npc.ai[2] = (Main.player[npc.target].Center - npc.Center).ToRotation() + MathHelper.PiOver2; npc.rotation = npc.rotation.AngleTowards(npc.ai[2], 0.104719758f); @@ -13817,13 +13836,13 @@ namespace CalamityMod.NPCs npc.netUpdate = true; float velocity = CalamityWorld.bossRushActive ? 16f : 12f; - Vector2 velocity6 = (npc.ai[2] - 1.57079637f).ToRotationVector2() * velocity; + Vector2 velocity6 = (npc.ai[2] - MathHelper.PiOver2).ToRotationVector2() * velocity; npc.velocity = velocity6 * 2f; for (int num1256 = 0; num1256 < Main.maxProjectiles; num1256++) { Projectile projectile9 = Main.projectile[num1256]; - if (projectile9.active && projectile9.type == ProjectileID.PhantasmalSphere && projectile9.ai[1] == (float)npc.whoAmI && projectile9.ai[0] != -1f) + if (projectile9.active && projectile9.type == ProjectileID.PhantasmalSphere && projectile9.ai[1] == npc.whoAmI && projectile9.ai[0] != -1f) { projectile9.ai[0] = -1f; projectile9.damage = 55; @@ -13857,9 +13876,9 @@ namespace CalamityMod.NPCs { npc.localAI[0] = 0f; - npc.localAI[1] = (float)Math.Sin((double)((num1245 - 15f) * 6.28318548f / 15f)) * 0.5f; + npc.localAI[1] = (float)Math.Sin((num1245 - 15f) * MathHelper.TwoPi / 15f) * 0.5f; if (npc.localAI[1] < 0f) - npc.localAI[0] = 3.14159274f; + npc.localAI[0] = MathHelper.Pi; } else { @@ -13879,7 +13898,7 @@ namespace CalamityMod.NPCs if (num1245 == 45f) { - npc.ai[2] = (float)(Main.rand.Next(2) == 0).ToDirectionInt() * 6.28318548f / 40f; + npc.ai[2] = (Main.rand.Next(2) == 0).ToDirectionInt() * MathHelper.TwoPi / 40f; npc.netUpdate = true; } @@ -13896,14 +13915,14 @@ namespace CalamityMod.NPCs float scaleFactor10 = MathHelper.Lerp(8f, 20f, (num1245 - 15f - 30f) / 140f); npc.velocity = Vector2.Normalize(vector218) * scaleFactor10; - npc.rotation = npc.rotation.AngleLerp(npc.velocity.ToRotation() + 1.57079637f, 0.2f); + npc.rotation = npc.rotation.AngleLerp(npc.velocity.ToRotation() + MathHelper.PiOver2, 0.2f); if ((num1245 - 15f - 30f) % 10f == 0f && Main.netMode != NetmodeID.MultiplayerClient) { Vector2 vector219 = npc.Center + Vector2.Normalize(vector218) * value22.Length() * 0.4f; float velocity = CalamityWorld.bossRushActive ? 14f : 10f; Vector2 vector220 = Vector2.Normalize(vector218) * velocity; - float ai3 = (6.28318548f * (float)Main.rand.NextDouble() - 3.14159274f) / 30f + 0.0174532924f * npc.ai[2]; + float ai3 = (MathHelper.TwoPi * (float)Main.rand.NextDouble() - MathHelper.Pi) / 30f + 0.0174532924f * npc.ai[2]; Projectile.NewProjectile(vector219.X, vector219.Y, vector220.X, vector220.Y, ProjectileID.PhantasmalEye, 35, 0f, Main.myPlayer, 0f, ai3); } } @@ -13946,9 +13965,9 @@ namespace CalamityMod.NPCs num1260 = 1.65f; } - Vector2 vector221 = center25 + ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * value22 / 2f; - int num1261 = Dust.NewDust(vector221 - Vector2.One * 8f, 16, 16, num1259, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, default(Color), 1f); - Main.dust[num1261].velocity = Vector2.Normalize(center25 - vector221) * 3.5f * (10f - (float)num1257 * 2f) / 10f; + Vector2 vector221 = center25 + ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * value22 / 2f; + int num1261 = Dust.NewDust(vector221 - Vector2.One * 8f, 16, 16, num1259, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, default, 1f); + Main.dust[num1261].velocity = Vector2.Normalize(center25 - vector221) * 3.5f * (10f - num1257 * 2f) / 10f; Main.dust[num1261].noGravity = true; Main.dust[num1261].scale = num1260; Main.dust[num1261].customData = npc; @@ -13977,9 +13996,9 @@ namespace CalamityMod.NPCs if (vector222.X < 0f) num1262 = 1f; - vector222 = vector222.RotatedBy((double)(-(double)num1262 * 6.28318548f / 6f), default(Vector2)); - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector222.X, vector222.Y, ProjectileID.PhantasmalDeathray, 50, 0f, Main.myPlayer, num1262 * 6.28318548f / calamityGlobalNPC.newAI[1], (float)npc.whoAmI); - npc.ai[2] = (vector222.ToRotation() + 9.424778f) * num1262; + vector222 = vector222.RotatedBy(-(double)num1262 * MathHelper.TwoPi / 6f, default); + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector222.X, vector222.Y, ProjectileID.PhantasmalDeathray, 50, 0f, Main.myPlayer, num1262 * MathHelper.TwoPi / calamityGlobalNPC.newAI[1], npc.whoAmI); + npc.ai[2] = (vector222.ToRotation() + MathHelper.Pi + MathHelper.TwoPi) * num1262; npc.netUpdate = true; } @@ -13987,16 +14006,16 @@ namespace CalamityMod.NPCs if (npc.localAI[1] > 1f) npc.localAI[1] = 1f; - float num1263 = (float)(npc.ai[2] >= 0f).ToDirectionInt(); + float num1263 = (npc.ai[2] >= 0f).ToDirectionInt(); float num1264 = npc.ai[2]; if (num1264 < 0f) num1264 *= -1f; - num1264 += -9.424778f; - num1264 += num1263 * 6.28318548f / calamityGlobalNPC.newAI[1]; + num1264 += -(MathHelper.Pi + MathHelper.TwoPi); + num1264 += num1263 * MathHelper.TwoPi / calamityGlobalNPC.newAI[1]; npc.localAI[0] = num1264; - npc.ai[2] = (num1264 + 9.424778f) * num1263; + npc.ai[2] = (num1264 + MathHelper.Pi + MathHelper.TwoPi) * num1263; return false; } @@ -14039,7 +14058,7 @@ namespace CalamityMod.NPCs for (int num1272 = 0; num1272 < Main.maxNPCs; num1272++) { - if (Main.npc[num1272].active && Main.npc[num1272].ai[3] == (float)num1268) + if (Main.npc[num1272].active && Main.npc[num1272].ai[3] == num1268) { if (num1269 == -1 && Main.npc[num1272].type == NPCID.MoonLordHand && Main.npc[num1272].ai[2] == 0f) num1269 = num1272; @@ -14126,20 +14145,20 @@ namespace CalamityMod.NPCs npc.Center = Vector2.Lerp(Main.projectile[num1267].Center, Main.npc[(int)Math.Abs(npc.ai[0]) - 1].Center + value28, npc.ai[2] / num1265); // Emit dust - Vector2 spinningpoint3 = Vector2.UnitY * (float)-(float)npc.height / 2f; + Vector2 spinningpoint3 = Vector2.UnitY * -npc.height / 2f; for (int num1286 = 0; num1286 < 6; num1286++) { - int num1287 = Dust.NewDust(npc.Center - Vector2.One * 4f + spinningpoint3.RotatedBy((double)((float)num1286 * 6.28318548f / 6f), default), 0, 0, 229, 0f, 0f, 0, default, 1f); + int num1287 = Dust.NewDust(npc.Center - Vector2.One * 4f + spinningpoint3.RotatedBy(num1286 * MathHelper.TwoPi / 6f, default), 0, 0, 229, 0f, 0f, 0, default, 1f); Main.dust[num1287].velocity = -Vector2.UnitY; Main.dust[num1287].noGravity = true; Main.dust[num1287].scale = 0.7f; Main.dust[num1287].customData = npc; } - spinningpoint3 = Vector2.UnitY * (float)-(float)npc.height / 6f; + spinningpoint3 = Vector2.UnitY * -npc.height / 6f; for (int num1288 = 0; num1288 < 3; num1288++) { - int num1289 = Dust.NewDust(npc.Center - Vector2.One * 4f + spinningpoint3.RotatedBy((double)((float)num1288 * 6.28318548f / 6f), default), 0, 0, 229, 0f, -2f, 0, default, 1f); + int num1289 = Dust.NewDust(npc.Center - Vector2.One * 4f + spinningpoint3.RotatedBy(num1288 * MathHelper.TwoPi / 6f, default), 0, 0, 229, 0f, -2f, 0, default, 1f); Main.dust[num1289].noGravity = true; Main.dust[num1289].scale = 1.5f; Main.dust[num1289].customData = npc; @@ -14926,7 +14945,7 @@ namespace CalamityMod.NPCs num877 = (float)Math.Sqrt((double)(num874 * num874 + num875 * num875)); if (num877 > 20f) - npc.rotation = (float)Math.Atan2((double)num875, (double)num874) + 1.57f; + npc.rotation = (float)Math.Atan2((double)num875, (double)num874) + MathHelper.PiOver2; } else if (npc.ai[2] == 1f) { @@ -14935,7 +14954,7 @@ namespace CalamityMod.NPCs float num880 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector114.Y; float num881 = (float)Math.Sqrt((double)(num879 * num879 + num880 * num880)); - npc.rotation = (float)Math.Atan2((double)num880, (double)num879) + 1.57f; + npc.rotation = (float)Math.Atan2((double)num880, (double)num879) + MathHelper.PiOver2; npc.velocity.X *= 0.95f; npc.velocity.Y -= 0.3f; @@ -14972,7 +14991,7 @@ namespace CalamityMod.NPCs float num884 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector115.Y; float num885 = (float)Math.Sqrt((double)(num883 * num883 + num884 * num884)); - npc.rotation = (float)Math.Atan2((double)num884, (double)num883) + 1.57f; + npc.rotation = (float)Math.Atan2((double)num884, (double)num883) + MathHelper.PiOver2; npc.velocity.Y *= 0.95f; npc.velocity.X += 0.3f * -npc.ai[0]; @@ -15292,10 +15311,10 @@ namespace CalamityMod.NPCs #region Revengeance Dungeon Guardian AI public static void RevengeanceDungeonGuardianAI(NPC npc, bool configBossRushBoost, bool enraged) { - Vector2 vector21 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num177 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector21.X; - float num178 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector21.Y; - float num179 = (float)Math.Sqrt((double)(num177 * num177 + num178 * num178)); + Vector2 vector21 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num177 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector21.X; + float num178 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector21.Y; + float num179 = (float)Math.Sqrt(num177 * num177 + num178 * num178); num179 = 12f / num179; npc.velocity.X = num177 * num179; npc.velocity.Y = num178 * num179; @@ -15309,13 +15328,13 @@ namespace CalamityMod.NPCs if (Collision.CanHit(vector16, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { float num159 = 5f; - float num160 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector16.X + (float)Main.rand.Next(-20, 21); - float num161 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector16.Y + (float)Main.rand.Next(-20, 21); - float num162 = (float)Math.Sqrt((double)(num160 * num160 + num161 * num161)); + float num160 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector16.X + Main.rand.Next(-20, 21); + float num161 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector16.Y + Main.rand.Next(-20, 21); + float num162 = (float)Math.Sqrt(num160 * num160 + num161 * num161); num162 = num159 / num162; num160 *= num162; num161 *= num162; - Vector2 value = new Vector2(num160 * 1f + (float)Main.rand.Next(-50, 51) * 0.01f, num161 * 1f + (float)Main.rand.Next(-50, 51) * 0.01f); + Vector2 value = new Vector2(num160 * 1f + Main.rand.Next(-50, 51) * 0.01f, num161 * 1f + Main.rand.Next(-50, 51) * 0.01f); value.Normalize(); value *= num159; value += npc.velocity; @@ -19701,7 +19720,7 @@ namespace CalamityMod.NPCs else if (num4 < 0f) { npc.spriteDirection = -1; - npc.rotation = (float)Math.Atan2((double)num5, (double)num4) + 3.14f; + npc.rotation = (float)Math.Atan2((double)num5, (double)num4) + MathHelper.Pi; } } else if (npc.type == 139) @@ -19733,12 +19752,12 @@ namespace CalamityMod.NPCs if (num4 < 0f) { npc.spriteDirection = -1; - npc.rotation = (float)Math.Atan2((double)num5, (double)num4) + 3.14f; + npc.rotation = (float)Math.Atan2((double)num5, (double)num4) + MathHelper.Pi; } } else if (npc.type == 6 || npc.type == 94 || npc.type == 173) { - npc.rotation = (float)Math.Atan2((double)num5, (double)num4) - 1.57f; + npc.rotation = (float)Math.Atan2((double)num5, (double)num4) - MathHelper.PiOver2; } else if (npc.type == 205) { @@ -19754,7 +19773,7 @@ namespace CalamityMod.NPCs } else { - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - 1.57f; + npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - MathHelper.PiOver2; } if (npc.type == 6 || npc.type == 23 || npc.type == 94 || npc.type == 139 || npc.type == 173 || npc.type == 205) { @@ -20290,7 +20309,7 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.SolarCrawltipedeHead) { - Vector2 value = npc.Center + (npc.rotation - 1.57079637f).ToRotationVector2() * 8f; + Vector2 value = npc.Center + (npc.rotation - MathHelper.PiOver2).ToRotationVector2() * 8f; Vector2 value2 = npc.rotation.ToRotationVector2() * 16f; Dust expr_1AAB = Main.dust[Dust.NewDust(value + value2, 0, 0, 6, npc.velocity.X, npc.velocity.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 3f)]; expr_1AAB.noGravity = true; @@ -20487,7 +20506,7 @@ namespace CalamityMod.NPCs catch { } - npc.rotation = (float)Math.Atan2((double)num40, (double)num39) + 1.57f; + npc.rotation = (float)Math.Atan2((double)num40, (double)num39) + MathHelper.PiOver2; num52 = (float)Math.Sqrt((double)(num39 * num39 + num40 * num40)); int num53 = npc.width; if (npc.type >= NPCID.WyvernHead && npc.type <= NPCID.WyvernTail) @@ -20722,7 +20741,7 @@ namespace CalamityMod.NPCs } } - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; + npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + MathHelper.PiOver2; if (npc.type == NPCID.DevourerHead || npc.type == NPCID.GiantWormHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.DiggerHead || npc.type == NPCID.SeekerHead || npc.type == NPCID.LeechHead || npc.type == NPCID.DuneSplicerHead || npc.type == NPCID.TombCrawlerHead) { if (flag2) @@ -22231,7 +22250,7 @@ namespace CalamityMod.NPCs bool flag17 = false; if (npc.directionY < 0) { - npc.rotation = (float)(Math.Atan2((double)num272, (double)num271) + 1.57); + npc.rotation = (float)(Math.Atan2((double)num272, (double)num271) + MathHelper.PiOver2); flag17 = ((double)npc.rotation >= -1.2 && (double)npc.rotation <= 1.2); if ((double)npc.rotation < -0.8) { @@ -22482,7 +22501,7 @@ namespace CalamityMod.NPCs npc.localAI[0] = 0f; for (int num1501 = 0; num1501 < 4; num1501++) { - Vector2 vector255 = new Vector2(0f, -5f).RotatedBy((double)(1.57079637f * (float)num1501), default); + Vector2 vector255 = new Vector2(0f, -5f).RotatedBy((double)(MathHelper.PiOver2 * (float)num1501), default); int proj = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector255.X, vector255.Y, ProjectileID.FlamesTrap, 20, 0f, Main.myPlayer, 0f, 0f); Main.projectile[proj].tileCollide = false; Main.projectile[proj].friendly = false; @@ -23351,7 +23370,7 @@ namespace CalamityMod.NPCs { Vector2 vector2 = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * -20f; Dust arg_5A4_0 = Main.dust[Dust.NewDust(vector2, 0, 0, 242, 0f, 0f, 0, default(Color), 1f)]; - Vector2 vector3 = Vector2.UnitY.RotatedByRandom(6.2831854820251465); + Vector2 vector3 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); arg_5A4_0.position = vector2 + vector3 * 20f; arg_5A4_0.velocity = -vector3 * 2f; arg_5A4_0.scale = 0.5f + vector3.X * (float)(-(float)npc.spriteDirection); @@ -23364,7 +23383,7 @@ namespace CalamityMod.NPCs { Vector2 vector4 = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * -20f; Dust arg_68B_0 = Main.dust[Dust.NewDust(vector4, 0, 0, 242, 0f, 0f, 0, default(Color), 1f)]; - Vector2 vector5 = Vector2.UnitY.RotatedByRandom(6.2831854820251465); + Vector2 vector5 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); arg_68B_0.position = vector4 + vector5 * 4f; arg_68B_0.velocity = vector5 * 4f + Vector2.UnitX * Main.rand.NextFloat() * (float)npc.spriteDirection * -5f; arg_68B_0.scale = 0.5f + vector5.X * (float)(-(float)npc.spriteDirection); @@ -24464,7 +24483,7 @@ namespace CalamityMod.NPCs } if (npc.type == 531) { - npc.rotation += 1.57079637f; + npc.rotation += MathHelper.PiOver2; } float num572 = 0.5f; if (npc.collideX) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 12dd74c0b4..7dc7cde80d 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -11,12 +11,16 @@ using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.Items.Ammo; using CalamityMod.Items.Dyes; +using CalamityMod.Items.Dyes.HairDye; using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; +using CalamityMod.Items.Placeables.Furniture.Fountains; using CalamityMod.Items.Placeables.Walls; using CalamityMod.Items.SummonItems; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Typeless; using CalamityMod.NPCs.Abyss; using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.AquaticScourge; @@ -68,6 +72,7 @@ using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; using Terraria.ModLoader.Config; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.NPCs { @@ -76,10 +81,12 @@ namespace CalamityMod.NPCs #region Variables public float DR { get; set; } = 0f; - /// - /// If this is set to true, the NPC's DR cannot be reduced via any means. This applies regardless of whether customDR is true or false. - /// - public bool unbreakableDR = false; + public int KillTime { get; set; } = 0; + + /// + /// If this is set to true, the NPC's DR cannot be reduced via any means. This applies regardless of whether customDR is true or false. + /// + public bool unbreakableDR = false; /// /// Overrides the normal DR math and uses custom DR reductions for each debuff, registered separately.

@@ -99,6 +106,7 @@ namespace CalamityMod.NPCs // NewAI internal const int maxAIMod = 4; public float[] newAI = new float[maxAIMod]; + public int AITimer = 0; // Town NPC Patreon private bool setNewName = true; @@ -141,6 +149,8 @@ namespace CalamityMod.NPCs public int clamDebuff = 0; public int sulphurPoison = 0; public int ladHearts = 0; + public int relicOfResilienceCooldown = 0; + public int relicOfResilienceWeakness = 0; // whoAmI Variables public static int[] bobbitWormBottom = new int[5]; @@ -273,27 +283,27 @@ namespace CalamityMod.NPCs ///
public static List AstrumDeusIDs = new List { - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType() + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType() }; public static List AquaticScourgeIDs = new List { - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType() + NPCType(), + NPCType(), + NPCType(), + NPCType() }; public static List DesertScourgeIDs = new List { - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType() + NPCType(), + NPCType(), + NPCType() }; public static List EaterofWorldsIDs = new List @@ -312,9 +322,9 @@ namespace CalamityMod.NPCs public static List StormWeaverIDs = new List { - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType() + NPCType(), + NPCType(), + NPCType() }; #endregion @@ -347,42 +357,42 @@ namespace CalamityMod.NPCs } for (int i = 0; i < bobbitWormBottom.Length; i++) - ResetSavedIndex(ref bobbitWormBottom[i], ModContent.NPCType()); + ResetSavedIndex(ref bobbitWormBottom[i], NPCType()); - ResetSavedIndex(ref hiveMind, ModContent.NPCType(), ModContent.NPCType()); - ResetSavedIndex(ref perfHive, ModContent.NPCType()); - ResetSavedIndex(ref slimeGodPurple, ModContent.NPCType(), ModContent.NPCType()); - ResetSavedIndex(ref slimeGodRed, ModContent.NPCType(), ModContent.NPCType()); - ResetSavedIndex(ref slimeGod, ModContent.NPCType()); + ResetSavedIndex(ref hiveMind, NPCType(), NPCType()); + ResetSavedIndex(ref perfHive, NPCType()); + ResetSavedIndex(ref slimeGodPurple, NPCType(), NPCType()); + ResetSavedIndex(ref slimeGodRed, NPCType(), NPCType()); + ResetSavedIndex(ref slimeGod, NPCType()); ResetSavedIndex(ref laserEye, NPCID.Retinazer); ResetSavedIndex(ref fireEye, NPCID.Spazmatism); ResetSavedIndex(ref primeLaser, NPCID.PrimeLaser); ResetSavedIndex(ref primeCannon, NPCID.PrimeCannon); ResetSavedIndex(ref primeVice, NPCID.PrimeVice); ResetSavedIndex(ref primeSaw, NPCID.PrimeSaw); - ResetSavedIndex(ref brimstoneElemental, ModContent.NPCType()); - ResetSavedIndex(ref cataclysm, ModContent.NPCType()); - ResetSavedIndex(ref catastrophe, ModContent.NPCType()); - ResetSavedIndex(ref calamitas, ModContent.NPCType()); - ResetSavedIndex(ref leviathan, ModContent.NPCType()); - ResetSavedIndex(ref siren, ModContent.NPCType()); - ResetSavedIndex(ref scavenger, ModContent.NPCType()); - ResetSavedIndex(ref astrumDeusHeadMain, ModContent.NPCType()); - ResetSavedIndex(ref energyFlame, ModContent.NPCType()); - ResetSavedIndex(ref doughnutBoss, ModContent.NPCType()); - ResetSavedIndex(ref holyBossAttacker, ModContent.NPCType()); - ResetSavedIndex(ref holyBossDefender, ModContent.NPCType()); - ResetSavedIndex(ref holyBossHealer, ModContent.NPCType()); - ResetSavedIndex(ref holyBoss, ModContent.NPCType()); - ResetSavedIndex(ref voidBoss, ModContent.NPCType()); - ResetSavedIndex(ref signus, ModContent.NPCType()); - ResetSavedIndex(ref ghostBossClone, ModContent.NPCType()); - ResetSavedIndex(ref ghostBoss, ModContent.NPCType()); - ResetSavedIndex(ref DoGHead, ModContent.NPCType(), ModContent.NPCType()); - ResetSavedIndex(ref SCalCataclysm, ModContent.NPCType()); - ResetSavedIndex(ref SCalCatastrophe, ModContent.NPCType()); - ResetSavedIndex(ref SCal, ModContent.NPCType()); - ResetSavedIndex(ref SCalWorm, ModContent.NPCType()); + ResetSavedIndex(ref brimstoneElemental, NPCType()); + ResetSavedIndex(ref cataclysm, NPCType()); + ResetSavedIndex(ref catastrophe, NPCType()); + ResetSavedIndex(ref calamitas, NPCType()); + ResetSavedIndex(ref leviathan, NPCType()); + ResetSavedIndex(ref siren, NPCType()); + ResetSavedIndex(ref scavenger, NPCType()); + ResetSavedIndex(ref astrumDeusHeadMain, NPCType()); + ResetSavedIndex(ref energyFlame, NPCType()); + ResetSavedIndex(ref doughnutBoss, NPCType()); + ResetSavedIndex(ref holyBossAttacker, NPCType()); + ResetSavedIndex(ref holyBossDefender, NPCType()); + ResetSavedIndex(ref holyBossHealer, NPCType()); + ResetSavedIndex(ref holyBoss, NPCType()); + ResetSavedIndex(ref voidBoss, NPCType()); + ResetSavedIndex(ref signus, NPCType()); + ResetSavedIndex(ref ghostBossClone, NPCType()); + ResetSavedIndex(ref ghostBoss, NPCType()); + ResetSavedIndex(ref DoGHead, NPCType(), NPCType()); + ResetSavedIndex(ref SCalCataclysm, NPCType()); + ResetSavedIndex(ref SCalCatastrophe, NPCType()); + ResetSavedIndex(ref SCal, NPCType()); + ResetSavedIndex(ref SCalWorm, NPCType()); } #endregion @@ -409,16 +419,16 @@ namespace CalamityMod.NPCs } bool inAbyss = ((npc.position.Y / 16f > (Main.rockLayer - Main.maxTilesY * 0.05)) && ((double)(npc.position.Y / 16f) <= Main.maxTilesY - 250) && abyssPosX) || CalamityWorld.abyssTiles > 200; - bool hurtByAbyss = npc.wet && npc.damage > 0 && !npc.boss && !npc.friendly && !npc.dontTakeDamage && inAbyss && !npc.buffImmune[ModContent.BuffType()]; + bool hurtByAbyss = npc.wet && npc.damage > 0 && !npc.boss && !npc.friendly && !npc.dontTakeDamage && inAbyss && !npc.buffImmune[BuffType()]; if (hurtByAbyss) { - npc.AddBuff(ModContent.BuffType(), 2); + npc.AddBuff(BuffType(), 2); npc.DeathSound = null; npc.HitSound = null; } if (npc.damage > 0 && !npc.boss && !npc.friendly && !npc.dontTakeDamage && CalamityWorld.sulphurTiles > 30 && - !npc.buffImmune[BuffID.Poisoned] && !npc.buffImmune[ModContent.BuffType()]) + !npc.buffImmune[BuffID.Poisoned] && !npc.buffImmune[BuffType()]) { if (npc.wet) { @@ -427,7 +437,7 @@ namespace CalamityMod.NPCs if (Main.raining) { - npc.AddBuff(ModContent.BuffType(), 2); + npc.AddBuff(BuffType(), 2); } } @@ -442,7 +452,7 @@ namespace CalamityMod.NPCs for (int j = 0; j < Main.maxProjectiles; j++) { if (Main.projectile[j].active && - (Main.projectile[j].type == ModContent.ProjectileType() || Main.projectile[j].type == ModContent.ProjectileType() || Main.projectile[j].type == ModContent.ProjectileType() || Main.projectile[j].type == ModContent.ProjectileType()) && + (Main.projectile[j].type == ProjectileType() || Main.projectile[j].type == ProjectileType() || Main.projectile[j].type == ProjectileType() || Main.projectile[j].type == ProjectileType()) && Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI) { projectileCount++; @@ -471,7 +481,7 @@ namespace CalamityMod.NPCs for (int j = 0; j < Main.maxProjectiles; j++) { if (Main.projectile[j].active && - (Main.projectile[j].type == ModContent.ProjectileType() && + (Main.projectile[j].type == ProjectileType() && Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI)) { projectileCount++; @@ -500,7 +510,7 @@ namespace CalamityMod.NPCs for (int j = 0; j < Main.maxProjectiles; j++) { if (Main.projectile[j].active && - (Main.projectile[j].type == ModContent.ProjectileType()) && + (Main.projectile[j].type == ProjectileType()) && Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI && projectileCount < 5) { @@ -528,9 +538,9 @@ namespace CalamityMod.NPCs { if (Main.projectile[j].active && Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI) { - if (Main.projectile[j].type == ModContent.ProjectileType()) + if (Main.projectile[j].type == ProjectileType()) projectileCount += 2; - if (Main.projectile[j].type == ModContent.ProjectileType()) + if (Main.projectile[j].type == ProjectileType()) projectileCount++; } } @@ -660,18 +670,27 @@ namespace CalamityMod.NPCs // Apply DR to vanilla NPCs. No vanilla NPCs have DR except in Rev+. // This also applies DR to other mods' NPCs who have set up their NPCs to have DR in Rev+. - if (CalamityWorld.revenge && CalamityMod.DRValues.ContainsKey(npc.type)) + if (CalamityWorld.revenge) { - CalamityMod.DRValues.TryGetValue(npc.type, out float revDR); - DR = revDR; - } + if (CalamityMod.DRValues.ContainsKey(npc.type)) + { + CalamityMod.DRValues.TryGetValue(npc.type, out float revDR); + DR = revDR; + } + + if (CalamityMod.bossKillTimes.ContainsKey(npc.type)) + { + CalamityMod.bossKillTimes.TryGetValue(npc.type, out int revKillTime); + KillTime = revKillTime; + } + } if (npc.boss && CalamityWorld.revenge) { - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType()) { if (Main.netMode != NetmodeID.Server) { @@ -721,12 +740,12 @@ namespace CalamityMod.NPCs { if (CalamityMod.enemyImmunityList.Contains(npc.type) || npc.boss) { - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; npc.buffImmune[BuffID.Webbed] = true; npc.buffImmune[BuffID.Slow] = true; } @@ -747,12 +766,12 @@ namespace CalamityMod.NPCs } } - if (npc.buffImmune[BuffID.Venom] == false) + if (!npc.buffImmune[BuffID.Venom]) { - npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[BuffType()] = false; } - npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[BuffType()] = false; } #endregion @@ -761,17 +780,17 @@ namespace CalamityMod.NPCs { if (!npc.friendly) { - npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[BuffType()] = false; - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; npc.buffImmune[BuffID.Webbed] = true; npc.buffImmune[BuffID.Slow] = true; } @@ -820,7 +839,7 @@ namespace CalamityMod.NPCs break; case NPCID.SkeletronPrime: - npc.lifeMax = (int)(npc.lifeMax * 1.45); + npc.lifeMax = (int)(npc.lifeMax * 1.9); npc.npcSlots = 12f; break; @@ -959,12 +978,8 @@ namespace CalamityMod.NPCs } else if (npc.type == NPCID.SkeletronPrime) { - npc.lifeMax = (int)(npc.lifeMax * 1.15); - npc.npcSlots = 12f; - } - else if (npc.type == NPCID.PrimeVice || npc.type == NPCID.PrimeCannon || npc.type == NPCID.PrimeSaw || npc.type == NPCID.PrimeLaser) - { - npc.lifeMax = (int)(npc.lifeMax * 0.9); + npc.lifeMax = (int)(npc.lifeMax * 1.45); + npc.npcSlots = 12f; } else if (npc.type == NPCID.Retinazer) { @@ -1135,6 +1150,7 @@ namespace CalamityMod.NPCs effects, 0f); } + public static void DrawAfterimage(NPC npc, SpriteBatch spriteBatch, Color startingColor, Color endingColor, Texture2D texture = null, Func rotationCalculation = null, bool directioning = false, bool invertedDirection = false) { @@ -1213,6 +1229,7 @@ namespace CalamityMod.NPCs case 1: scalar = 1.0; break; + case 2: scalar = 0.76; break; @@ -1259,80 +1276,80 @@ namespace CalamityMod.NPCs } else if (npc.type == thorium.NPCType("TheGrandThunderBirdv2")) { - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; npc.lifeMax = (int)(npc.lifeMax * 1.5); } else if (npc.type == thorium.NPCType("QueenJelly")) { - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; npc.lifeMax = (int)(npc.lifeMax * 1.35); } else if (npc.type == thorium.NPCType("Viscount")) { - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; npc.lifeMax = (int)(npc.lifeMax * 1.25); } else if (npc.type == thorium.NPCType("GraniteEnergyStorm")) { - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; npc.lifeMax = (int)(npc.lifeMax * 1.1); } else if (npc.type == thorium.NPCType("TheBuriedWarrior") || npc.type == thorium.NPCType("TheBuriedWarrior1") || npc.type == thorium.NPCType("TheBuriedWarrior2")) { - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; npc.lifeMax = (int)(npc.lifeMax * 1.2); } else if (npc.type == thorium.NPCType("ThePrimeScouter") || npc.type == thorium.NPCType("CryoCore") || npc.type == thorium.NPCType("BioCore") || npc.type == thorium.NPCType("PyroCore")) { - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; npc.lifeMax = (int)(npc.lifeMax * 1.3); } else if (npc.type == thorium.NPCType("BoreanStrider") || npc.type == thorium.NPCType("BoreanStriderPopped")) { - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; npc.lifeMax = (int)(npc.lifeMax * 1.4); } else if (npc.type == thorium.NPCType("FallenDeathBeholder") || npc.type == thorium.NPCType("FallenDeathBeholder2")) { - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; npc.lifeMax = (int)(npc.lifeMax * 1.6); } else if (npc.type == thorium.NPCType("Lich") || npc.type == thorium.NPCType("LichHeadless")) { - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; npc.lifeMax = (int)(npc.lifeMax * 1.6); } else if (npc.type == thorium.NPCType("Abyssion") || npc.type == thorium.NPCType("AbyssionCracked") || npc.type == thorium.NPCType("AbyssionReleased")) { - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; npc.lifeMax = (int)(npc.lifeMax * 1.5); } else if (npc.type == thorium.NPCType("SlagFury") || npc.type == thorium.NPCType("Omnicide") || npc.type == thorium.NPCType("RealityBreaker") || npc.type == thorium.NPCType("Aquaius") || npc.type == thorium.NPCType("Aquaius2")) { - npc.buffImmune[ModContent.BuffType()] = true; - npc.buffImmune[ModContent.BuffType()] = true; + npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = true; npc.lifeMax = (int)(npc.lifeMax * 1.3); } @@ -1370,6 +1387,12 @@ namespace CalamityMod.NPCs damage /= 2; } + if (relicOfResilienceWeakness > 0) + { + damage = (int)(damage * (1f - RelicOfResilience.WeaknessDR)); + relicOfResilienceWeakness = 0; + } + if (modTarget.beeResist) { if (CalamityMod.beeEnemyList.Contains(npc.type)) @@ -1391,8 +1414,7 @@ namespace CalamityMod.NPCs #region Strike NPC public override bool StrikeNPC(NPC npc, ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { - Mod chaos = ModLoader.GetMod("ChaosMod"); - if ((CalamityWorld.revenge && chaos == null) || CalamityWorld.bossRushActive) + if (CalamityWorld.revenge || CalamityWorld.bossRushActive) { if (DestroyerIDs.Contains(npc.type)) { @@ -1467,7 +1489,7 @@ namespace CalamityMod.NPCs /// private double ApplyDR(NPC npc, double damage) { - if (DR <= 0f || damage <= 1.0) + if ((DR <= 0f && KillTime == 0) || damage <= 1.0) return damage; // If the NPC currently has unbreakable DR, it cannot be reduced by any means. @@ -1478,7 +1500,28 @@ namespace CalamityMod.NPCs if (effectiveDR <= 0f) effectiveDR = 0f; - double newDamage = (1f - effectiveDR) * damage; + // Calculate extra DR based on kill time, similar to the Hush boss from The Binding of Isaac + if (KillTime > 0 && AITimer < KillTime && !CalamityWorld.bossRushActive) + { + // The limit for how much extra DR the boss can have + float extraDRLimit = (1f - DR) * (!GetDownedBossVariable(npc.type) || CalamityMod.CalamityConfig.ExtraBossDR ? 1.5f : 1f); + + // Ranges from 1 to 0 + float currentHPRatio = npc.life / (float)npc.lifeMax; + + // Ranges from 0 to 1 + float killTimeRatio = AITimer / (float)KillTime; + + // If the player is damaging the boss too quickly + float extraDRScalar = currentHPRatio + killTimeRatio; + if (extraDRScalar < 1f) + { + // Ranges from 0 to (extraDRLimit / 2) + effectiveDR += extraDRLimit - (extraDRLimit / (1f + (1f - extraDRScalar))); + } + } + + double newDamage = (1f - effectiveDR) * damage; return newDamage < 1.0 ? 1.0 : newDamage; } @@ -1569,7 +1612,7 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.BrainofCthulhu) { - if ((float)npc.life / (float)npc.lifeMax < (CalamityWorld.death ? 0.33f : 0.2f)) + if (npc.life / (float)npc.lifeMax < (CalamityWorld.death ? 0.33f : 0.2f)) index = -1; } @@ -1577,7 +1620,7 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.DukeFishron) { - if ((float)npc.life / (float)npc.lifeMax < 0.15f) + if (npc.life / (float)npc.lifeMax < 0.15f) index = -1; } } @@ -1590,7 +1633,10 @@ namespace CalamityMod.NPCs { SetPatreonTownNPCName(npc); - if (npc.type == NPCID.TargetDummy || npc.type == ModContent.NPCType()) + if (KillTime > 0 && AITimer < KillTime) + AITimer++; + + if (npc.type == NPCID.TargetDummy || npc.type == NPCType()) { npc.chaseable = !CalamityPlayer.areThereAnyDamnBosses; npc.dontTakeDamage = CalamityPlayer.areThereAnyDamnBosses; @@ -1598,7 +1644,7 @@ namespace CalamityMod.NPCs if (DestroyerIDs.Contains(npc.type) || EaterofWorldsIDs.Contains(npc.type)) { - npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[BuffType()] = false; } if (npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall || npc.type == NPCID.Hornet || npc.type == NPCID.HornetFatty || npc.type == NPCID.HornetHoney || @@ -1618,77 +1664,79 @@ namespace CalamityMod.NPCs BossRushForceDespawnOtherNPCs(npc, mod); } - Mod chaos = ModLoader.GetMod("ChaosMod"); - if ((CalamityWorld.revenge && chaos == null) || CalamityWorld.bossRushActive) + if (CalamityWorld.revenge || CalamityWorld.bossRushActive) { - switch (npc.type) + Mod chaos = ModLoader.GetMod("ChaosMod"); + bool chaosMode = chaos != null; + + switch (npc.type) { case NPCID.KingSlime: - return CalamityGlobalAI.BuffedKingSlimeAI(npc, mod); + return CalamityGlobalAI.BuffedKingSlimeAI(npc, mod, chaosMode); case NPCID.EyeofCthulhu: - return CalamityGlobalAI.BuffedEyeofCthulhuAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedEyeofCthulhuAI(npc, enraged > 0, mod, chaosMode); case NPCID.EaterofWorldsHead: case NPCID.EaterofWorldsBody: case NPCID.EaterofWorldsTail: - return CalamityGlobalAI.BuffedEaterofWorldsAI(npc, mod); + return CalamityGlobalAI.BuffedEaterofWorldsAI(npc, mod, chaosMode); case NPCID.BrainofCthulhu: - return CalamityGlobalAI.BuffedBrainofCthulhuAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedBrainofCthulhuAI(npc, enraged > 0, mod, chaosMode); case NPCID.Creeper: - return CalamityGlobalAI.BuffedCreeperAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedCreeperAI(npc, enraged > 0, mod, chaosMode); case NPCID.QueenBee: - return CalamityGlobalAI.BuffedQueenBeeAI(npc, mod); + return CalamityGlobalAI.BuffedQueenBeeAI(npc, mod, chaosMode); case NPCID.SkeletronHand: - return CalamityGlobalAI.BuffedSkeletronHandAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedSkeletronHandAI(npc, enraged > 0, mod, chaosMode); case NPCID.SkeletronHead: - return CalamityGlobalAI.BuffedSkeletronAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedSkeletronAI(npc, enraged > 0, mod, chaosMode); case NPCID.WallofFlesh: - return CalamityGlobalAI.BuffedWallofFleshAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedWallofFleshAI(npc, enraged > 0, mod, chaosMode); case NPCID.WallofFleshEye: - return CalamityGlobalAI.BuffedWallofFleshEyeAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedWallofFleshEyeAI(npc, enraged > 0, mod, chaosMode); case NPCID.TheDestroyer: case NPCID.TheDestroyerBody: case NPCID.TheDestroyerTail: - return CalamityGlobalAI.BuffedDestroyerAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedDestroyerAI(npc, enraged > 0, mod, chaosMode); case NPCID.Retinazer: - return CalamityGlobalAI.BuffedRetinazerAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedRetinazerAI(npc, enraged > 0, mod, chaosMode); case NPCID.Spazmatism: - return CalamityGlobalAI.BuffedSpazmatismAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedSpazmatismAI(npc, enraged > 0, mod, chaosMode); case NPCID.SkeletronPrime: - return CalamityGlobalAI.BuffedSkeletronPrimeAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedSkeletronPrimeAI(npc, enraged > 0, mod, chaosMode); case NPCID.PrimeLaser: - return CalamityGlobalAI.BuffedPrimeLaserAI(npc, mod); + return CalamityGlobalAI.BuffedPrimeLaserAI(npc, mod, chaosMode); case NPCID.PrimeCannon: - return CalamityGlobalAI.BuffedPrimeCannonAI(npc, mod); + return CalamityGlobalAI.BuffedPrimeCannonAI(npc, mod, chaosMode); case NPCID.PrimeVice: - return CalamityGlobalAI.BuffedPrimeViceAI(npc, mod); + return CalamityGlobalAI.BuffedPrimeViceAI(npc, mod, chaosMode); case NPCID.PrimeSaw: - return CalamityGlobalAI.BuffedPrimeSawAI(npc, mod); + return CalamityGlobalAI.BuffedPrimeSawAI(npc, mod, chaosMode); case NPCID.Plantera: - return CalamityGlobalAI.BuffedPlanteraAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedPlanteraAI(npc, enraged > 0, mod, chaosMode); case NPCID.PlanterasHook: - return CalamityGlobalAI.BuffedPlanterasHookAI(npc, mod); + return CalamityGlobalAI.BuffedPlanterasHookAI(npc, mod, chaosMode); case NPCID.PlanterasTentacle: - return CalamityGlobalAI.BuffedPlanterasTentacleAI(npc, mod); + return CalamityGlobalAI.BuffedPlanterasTentacleAI(npc, mod, chaosMode); case NPCID.Golem: - return CalamityGlobalAI.BuffedGolemAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedGolemAI(npc, enraged > 0, mod, chaosMode); case NPCID.GolemHead: - return CalamityGlobalAI.BuffedGolemHeadAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedGolemHeadAI(npc, enraged > 0, mod, chaosMode); case NPCID.GolemHeadFree: - return CalamityGlobalAI.BuffedGolemHeadFreeAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedGolemHeadFreeAI(npc, enraged > 0, mod, chaosMode); case NPCID.DukeFishron: - return CalamityGlobalAI.BuffedDukeFishronAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedDukeFishronAI(npc, enraged > 0, mod, chaosMode); case NPCID.Pumpking: if (CalamityWorld.downedDoG) @@ -1724,19 +1772,18 @@ namespace CalamityMod.NPCs case NPCID.CultistBoss: case NPCID.CultistBossClone: - return CalamityGlobalAI.BuffedCultistAI(npc, enraged > 0, mod); + return CalamityGlobalAI.BuffedCultistAI(npc, enraged > 0, mod, chaosMode); case NPCID.AncientLight: - return CalamityGlobalAI.BuffedAncientLightAI(npc, mod); + return CalamityGlobalAI.BuffedAncientLightAI(npc, mod, chaosMode); case NPCID.AncientDoom: - return CalamityGlobalAI.BuffedAncientDoomAI(npc, mod); + return CalamityGlobalAI.BuffedAncientDoomAI(npc, mod, chaosMode); case NPCID.MoonLordCore: case NPCID.MoonLordHand: case NPCID.MoonLordHead: case NPCID.MoonLordFreeEye: case NPCID.MoonLordLeechBlob: - return CalamityGlobalAI.BuffedMoonLordAI(npc, enraged > 0, mod); - + return CalamityGlobalAI.BuffedMoonLordAI(npc, enraged > 0, mod, chaosMode); default: break; @@ -1748,11 +1795,11 @@ namespace CalamityMod.NPCs switch (npc.aiStyle) { case 1: - if (npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType() || - npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType() || - npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType() || - npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType() || - npc.type == ModContent.NPCType()) + if (npc.type == NPCType() || npc.type == NPCType() || + npc.type == NPCType() || npc.type == NPCType() || + npc.type == NPCType() || npc.type == NPCType() || + npc.type == NPCType() || npc.type == NPCType() || + npc.type == NPCType()) { return CalamityGlobalAI.BuffedSlimeAI(npc, mod); } @@ -1786,7 +1833,7 @@ namespace CalamityMod.NPCs } break; case 2: - if (npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType()) + if (npc.type == NPCType() || npc.type == NPCType()) { return CalamityGlobalAI.BuffedDemonEyeAI(npc, mod); } @@ -1812,8 +1859,8 @@ namespace CalamityMod.NPCs } break; case 3: - if (npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType() || - npc.type == ModContent.NPCType()) + if (npc.type == NPCType() || npc.type == NPCType() || + npc.type == NPCType()) { return CalamityGlobalAI.BuffedFighterAI(npc, mod); } @@ -2089,7 +2136,7 @@ namespace CalamityMod.NPCs } break; case 14: - if (npc.type == ModContent.NPCType()) + if (npc.type == NPCType()) { return CalamityGlobalAI.BuffedBatAI(npc, mod); } @@ -2291,7 +2338,7 @@ namespace CalamityMod.NPCs } break; case 91: - if (npc.type == ModContent.NPCType()) + if (npc.type == NPCType()) { return CalamityGlobalAI.BuffedGraniteElementalAI(npc, mod); } @@ -2308,7 +2355,7 @@ namespace CalamityMod.NPCs break; } } - else if (Main.expertMode && chaos == null) + else if (Main.expertMode) { if (npc.type == NPCID.FungiSpore || npc.type == NPCID.Spore) return CalamityGlobalAI.BuffedSporeAI(npc, mod, false); @@ -2327,7 +2374,7 @@ namespace CalamityMod.NPCs switch (npc.type) { case NPCID.Guide: - switch (Main.rand.Next(37)) // 34 guide names + switch (Main.rand.Next(38)) // 34 guide names { case 0: npc.GivenName = "Lapp"; @@ -2341,6 +2388,10 @@ namespace CalamityMod.NPCs npc.GivenName = "StreakistYT"; break; + case 3: + npc.GivenName = "Neoplasmatic"; + break; + default: break; } @@ -2348,7 +2399,7 @@ namespace CalamityMod.NPCs break; case NPCID.Wizard: - switch (Main.rand.Next(25)) // 23 wizard names + switch (Main.rand.Next(26)) // 23 wizard names { case 0: npc.GivenName = "Mage One-Trick"; @@ -2358,6 +2409,10 @@ namespace CalamityMod.NPCs npc.GivenName = "Inorim, son of Ivukey"; break; + case 2: + npc.GivenName = "Jensen"; + break; + default: break; } @@ -2550,7 +2605,7 @@ namespace CalamityMod.NPCs break; case 2: - if (npc.type != NPCID.KingSlime && npc.type != NPCID.BlueSlime && npc.type != NPCID.SlimeSpiked && npc.type != ModContent.NPCType() && + if (npc.type != NPCID.KingSlime && npc.type != NPCID.BlueSlime && npc.type != NPCID.SlimeSpiked && npc.type != NPCType() && npc.type != NPCID.YellowSlime && npc.type != NPCID.PurpleSlime && npc.type != NPCID.GreenSlime && npc.type != NPCID.RedSlime && npc.type != NPCID.IceSlime && npc.type != NPCID.UmbrellaSlime && npc.type != NPCID.RainbowSlime && npc.type != NPCID.Pinky) { @@ -2590,8 +2645,8 @@ namespace CalamityMod.NPCs break; case 6: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2609,7 +2664,7 @@ namespace CalamityMod.NPCs break; case 8: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2636,7 +2691,7 @@ namespace CalamityMod.NPCs break; case 11: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && + if (npc.type != NPCType() && npc.type != NPCType() && npc.type != NPCID.Spazmatism && npc.type != NPCID.Retinazer) { npc.active = false; @@ -2657,9 +2712,9 @@ namespace CalamityMod.NPCs break; case 13: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2677,10 +2732,10 @@ namespace CalamityMod.NPCs break; case 15: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2689,11 +2744,11 @@ namespace CalamityMod.NPCs break; case 16: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2702,11 +2757,11 @@ namespace CalamityMod.NPCs break; case 17: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2727,7 +2782,7 @@ namespace CalamityMod.NPCs break; case 19: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2746,8 +2801,8 @@ namespace CalamityMod.NPCs break; case 21: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2756,11 +2811,11 @@ namespace CalamityMod.NPCs break; case 22: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2769,9 +2824,9 @@ namespace CalamityMod.NPCs break; case 23: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2780,7 +2835,7 @@ namespace CalamityMod.NPCs break; case 24: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2789,8 +2844,8 @@ namespace CalamityMod.NPCs break; case 25: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2799,11 +2854,11 @@ namespace CalamityMod.NPCs break; case 26: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2832,8 +2887,8 @@ namespace CalamityMod.NPCs break; case 29: - if (!AstrumDeusIDs.Contains(npc.type) && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + if (!AstrumDeusIDs.Contains(npc.type) && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2842,8 +2897,8 @@ namespace CalamityMod.NPCs break; case 30: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2852,9 +2907,9 @@ namespace CalamityMod.NPCs break; case 31: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2863,9 +2918,9 @@ namespace CalamityMod.NPCs break; case 32: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2874,9 +2929,9 @@ namespace CalamityMod.NPCs break; case 33: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2885,11 +2940,11 @@ namespace CalamityMod.NPCs break; case 34: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2898,8 +2953,8 @@ namespace CalamityMod.NPCs break; case 35: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2908,11 +2963,11 @@ namespace CalamityMod.NPCs break; case 36: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2921,8 +2976,8 @@ namespace CalamityMod.NPCs break; case 37: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2931,8 +2986,8 @@ namespace CalamityMod.NPCs break; case 38: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType()) + if (npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2949,10 +3004,10 @@ namespace CalamityMod.NPCs if (!CalamityWorld.spawnedHardBoss) { if (npc.type == NPCID.TheDestroyer || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer || npc.type == NPCID.SkeletronPrime || - npc.type == NPCID.Plantera || npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType() || - npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType() || - npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType() || - npc.type == ModContent.NPCType() || npc.type == NPCID.DukeFishron || npc.type == NPCID.CultistBoss || npc.type == NPCID.Golem) + npc.type == NPCID.Plantera || npc.type == NPCType() || npc.type == NPCType() || + npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType() || + npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType() || + npc.type == NPCType() || npc.type == NPCID.DukeFishron || npc.type == NPCID.CultistBoss || npc.type == NPCID.Golem) { CalamityWorld.spawnedHardBoss = true; CalamityMod.UpdateServerBoolean(); @@ -3046,7 +3101,11 @@ namespace CalamityMod.NPCs clamDebuff--; if (sulphurPoison > 0) sulphurPoison--; - if (ladHearts > 0) + if (relicOfResilienceCooldown > 0) + relicOfResilienceCooldown--; + if (relicOfResilienceWeakness > 0) + relicOfResilienceWeakness--; + if (ladHearts > 0) ladHearts--; // Bosses and any specific other NPCs are completely immune to having their movement impaired. @@ -3080,21 +3139,21 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.Demon || npc.type == NPCID.VoodooDemon || npc.type == NPCID.RedDevil) { - target.AddBuff(ModContent.BuffType(), 36000); + target.AddBuff(BuffType(), 36000); } } switch (npc.type) { case NPCID.Golem: - target.AddBuff(ModContent.BuffType(), 300); + target.AddBuff(BuffType(), 300); break; case NPCID.GolemHead: case NPCID.GolemHeadFree: case NPCID.GolemFistRight: case NPCID.GolemFistLeft: - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffType(), 180); break; case NPCID.Lavabat: @@ -3115,7 +3174,7 @@ namespace CalamityMod.NPCs case NPCID.AngryBonesBig: case NPCID.AngryBonesBigMuscle: case NPCID.AngryBonesBigHelmet: - target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(BuffType(), 60); break; default: @@ -3138,7 +3197,7 @@ namespace CalamityMod.NPCs case NPCID.HellArmoredBonesSpikeShield: case NPCID.HellArmoredBonesMace: case NPCID.HellArmoredBonesSword: - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffType(), 120); break; default: @@ -3173,15 +3232,15 @@ namespace CalamityMod.NPCs npc.type == thorium.NPCType("Omnicide") || npc.type == thorium.NPCType("RealityBreaker") || npc.type == thorium.NPCType("Aquaius") || npc.type == thorium.NPCType("Aquaius2")) { - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffType(), 180); } else if (npc.type == thorium.NPCType("ViscountBaby") || npc.type == thorium.NPCType("EnemyBeholder") || npc.type == thorium.NPCType("AbyssalSpawn") || npc.type == thorium.NPCType("Viscount") || npc.type == thorium.NPCType("FallenDeathBeholder") || npc.type == thorium.NPCType("FallenDeathBeholder2") || npc.type == thorium.NPCType("Lich") || npc.type == thorium.NPCType("LichHeadless") || npc.type == thorium.NPCType("Abyssion") || npc.type == thorium.NPCType("AbyssionCracked") || npc.type == thorium.NPCType("AbyssionReleased")) { - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffType(), 180); + target.AddBuff(BuffType(), 180); } } } @@ -3198,7 +3257,7 @@ namespace CalamityMod.NPCs case NPCID.FaceMonster: case NPCID.BloodCrawler: case NPCID.BloodCrawlerWall: - target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(BuffType(), 60); break; case NPCID.DevourerHead: @@ -3228,7 +3287,7 @@ namespace CalamityMod.NPCs case NPCID.CrimsonGoldfish: case NPCID.CrimsonPenguin: case NPCID.Drippler: - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffType(), 120); break; case NPCID.EyeofCthulhu: @@ -3256,26 +3315,26 @@ namespace CalamityMod.NPCs case NPCID.Medusa: case NPCID.SandsharkCorrupt: case NPCID.SandsharkCrimson: - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffType(), 180); break; case NPCID.MourningWood: case NPCID.Pumpking: - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(BuffType(), 240); break; case NPCID.WallofFlesh: case NPCID.Krampus: - target.AddBuff(ModContent.BuffType(), 300); + target.AddBuff(BuffType(), 300); break; case NPCID.DungeonGuardian: - target.AddBuff(ModContent.BuffType(), 1200); + target.AddBuff(BuffType(), 1200); break; case NPCID.Creeper: - target.AddBuff(ModContent.BuffType(), 60); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffType(), 60); + target.AddBuff(BuffType(), 120); break; case NPCID.CursedSkull: @@ -3284,48 +3343,48 @@ namespace CalamityMod.NPCs case NPCID.TheHungryII: case NPCID.PumpkingBlade: case NPCID.BloodZombie: - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffType(), 120); + target.AddBuff(BuffType(), 120); break; case NPCID.DarkMummy: - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffType(), 180); + target.AddBuff(BuffType(), 120); break; case NPCID.EaterofWorldsHead: case NPCID.GiantCursedSkull: case NPCID.Butcher: case NPCID.Psycho: - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffType(), 180); + target.AddBuff(BuffType(), 180); break; case NPCID.Wraith: case NPCID.VampireBat: case NPCID.Vampire: case NPCID.Reaper: - target.AddBuff(ModContent.BuffType(), 240); - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffType(), 240); + target.AddBuff(BuffType(), 180); break; case NPCID.AncientCultistSquidhead: - target.AddBuff(ModContent.BuffType(), 240); - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(BuffType(), 240); + target.AddBuff(BuffType(), 240); break; case NPCID.DungeonSpirit: - target.AddBuff(ModContent.BuffType(), 300); - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffType(), 300); + target.AddBuff(BuffType(), 180); break; case NPCID.AncientDoom: - target.AddBuff(ModContent.BuffType(), 300); - target.AddBuff(ModContent.BuffType(), 300); + target.AddBuff(BuffType(), 300); + target.AddBuff(BuffType(), 300); break; case NPCID.Snatcher: - target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(BuffType(), 60); break; case NPCID.BurningSphere: @@ -3333,7 +3392,7 @@ namespace CalamityMod.NPCs case NPCID.Mummy: case NPCID.EnchantedSword: case NPCID.Werewolf: - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffType(), 120); break; case NPCID.Spazmatism: @@ -3347,22 +3406,22 @@ namespace CalamityMod.NPCs case NPCID.Sharkron2: case NPCID.ShadowFlameApparition: case NPCID.MartianDrone: - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffType(), 180); break; case NPCID.Mimic: case NPCID.AngryTrapper: - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(BuffType(), 240); break; case NPCID.DetonatingBubble: - target.AddBuff(ModContent.BuffType(), 360); + target.AddBuff(BuffType(), 360); break; case NPCID.PrimeSaw: case NPCID.PrimeVice: target.AddBuff(BuffID.Bleeding, 300); - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffType(), 180); break; case NPCID.SkeletronPrime: @@ -3378,7 +3437,7 @@ namespace CalamityMod.NPCs case NPCID.GolemFistRight: case NPCID.GolemFistLeft: target.AddBuff(BuffID.BrokenArmor, 180); - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffType(), 180); break; default: @@ -3436,54 +3495,51 @@ namespace CalamityMod.NPCs } } - NPCResists(npc, projectile, damage); - } - - #region NPC Resists - private void NPCResists(NPC npc, Projectile projectile, int damage) - { - Player player = Main.player[projectile.owner]; if (AstrumDeusIDs.Contains(npc.type)) { - if (projectile.type == ModContent.ProjectileType() || ProjectileID.Sets.StardustDragon[projectile.type]) + if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || ProjectileID.Sets.StardustDragon[projectile.type]) { damage = (int)(damage * 0.1); } - else if (projectile.type == ProjectileID.DD2BetsyArrow || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + else if (projectile.type == ProjectileID.Wasp || projectile.type == player.beeType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileID.DD2BetsyArrow) { - damage = (int)(damage * 0.2); + damage = (int)(damage * 0.4); } - else if (projectile.type == ModContent.ProjectileType()) - { - damage = (int)(damage * 0.3); - } - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ProjectileID.Wasp || projectile.type == player.beeType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + else if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType()) { damage = (int)(damage * 0.5); } + else if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) + { + damage = (int)(damage * 0.6); + } + else if (projectile.type == ProjectileType()) + { + damage = (int)(damage * 0.85); + } if (projectile.penetrate == -1 && !projectile.minion) { damage = (int)(damage * 0.2); } - else if (projectile.penetrate > 1 && projectile.type != ModContent.ProjectileType()) + else if (projectile.penetrate > 1 && projectile.type != ProjectileType()) { damage /= projectile.penetrate; } } else if (StormWeaverIDs.Contains(npc.type)) { - if (projectile.type == ModContent.ProjectileType()) + if (projectile.type == ProjectileType()) { damage = (int)(damage * 0.9); } - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + else if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) { if (projectile.penetrate == -1) projectile.penetrate = projectile.Calamity().stealthStrike ? 6 : 9; damage = (int)(damage * 0.75); } - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + else if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) { damage = (int)(damage * 0.5); } @@ -3503,38 +3559,26 @@ namespace CalamityMod.NPCs } else if (DestroyerIDs.Contains(npc.type)) { - if (((projectile.penetrate == -1 || projectile.penetrate > 1) && !projectile.minion) || projectile.type == ModContent.ProjectileType()) + if (((projectile.penetrate == -1 || projectile.penetrate > 1) && !projectile.minion)) { damage = (int)(damage * 0.5); } - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType()) { damage = (int)(damage * 0.75); } - else if (projectile.type == ModContent.ProjectileType()) + else if (projectile.type == ProjectileType()) { damage = (int)(damage * 0.5); } - else if (projectile.type == ModContent.ProjectileType()) + else if (projectile.type == ProjectileType()) { damage = (int)(damage * 0.38); } - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + else if (projectile.type == ProjectileType()) { damage = (int)(damage * 0.25); } - else if (projectile.type == ModContent.ProjectileType()) - { - if (projectile.penetrate == -1) - projectile.penetrate = 1; - damage = (int)(damage * 0.1); - } - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - { - if (projectile.penetrate == -1) - projectile.penetrate = 1; - damage = (int)(damage * 0.01); - } } else if (AquaticScourgeIDs.Contains(npc.type)) { @@ -3542,19 +3586,19 @@ namespace CalamityMod.NPCs { damage = (int)(damage * 0.5); } - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) + { + damage = (int)(damage * 0.9); + } + if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) { damage = (int)(damage * 0.5); } - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - { - damage = (int)(damage * 0.25); - } - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + else if (projectile.type == ProjectileType()) { if (projectile.penetrate == -1) - projectile.penetrate = 1; - damage = (int)(damage * 0.01); + projectile.penetrate = 2; + damage = (int)(damage * 0.1); } } else if (EaterofWorldsIDs.Contains(npc.type) || npc.type == NPCID.Creeper) @@ -3563,64 +3607,63 @@ namespace CalamityMod.NPCs { damage = (int)(damage * 0.6); } - if (projectile.type == ModContent.ProjectileType()) + if (projectile.type == ProjectileType()) { damage = (int)(damage * 0.7); } } else if (DesertScourgeIDs.Contains(npc.type)) { - if (projectile.type == ModContent.ProjectileType()) + if (projectile.type == ProjectileType()) { damage = (int)(damage * 0.7); } } - else if (npc.type == ModContent.NPCType()) + else if (npc.type == NPCType()) { - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + if (projectile.type == ProjectileType()) { damage = (int)(damage * 0.2); } - else if (projectile.type == ModContent.ProjectileType()) + else if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) { damage = (int)(damage * 0.5); } - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + else if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) { damage = (int)(damage * 0.6); } - else if (projectile.type == ModContent.ProjectileType()) + else if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType()) { damage = (int)(damage * 0.75); } - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ProjectileID.LunarFlare) + else if (projectile.type == ProjectileID.LunarFlare) { damage = (int)(damage * 0.8); } } else if (npc.type == NPCID.CultistBoss) { - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) { damage = (int)(damage * 0.75); } } else if (npc.type == NPCID.DukeFishron) { - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) { damage = (int)(damage * 1.35); } } - else if (npc.type == ModContent.NPCType()) + else if (npc.type == NPCType()) { - if (projectile.type == ModContent.ProjectileType()) + if (projectile.type == ProjectileType()) { damage = (int)(damage * 1.5); } } } - #endregion #endregion #region On Hit By Item @@ -3656,23 +3699,13 @@ namespace CalamityMod.NPCs { if (isSummon && npc.damage > 0) { - switch (Main.rand.Next(3)) - { - case 0: - player.AddBuff(ModContent.BuffType(), 120); - break; - - case 1: - player.AddBuff(ModContent.BuffType(), 120); - break; - - case 2: - player.AddBuff(ModContent.BuffType(), 120); - break; - - default: - break; - } + int buffType = Utils.SelectRandom(Main.rand, new int[] + { + BuffType(), + BuffType(), + BuffType() + }); + player.AddBuff(buffType, 120); } } @@ -3680,23 +3713,13 @@ namespace CalamityMod.NPCs { if (isSummon && npc.damage > 0) { - switch (Main.rand.Next(3)) - { - case 0: - player.AddBuff(ModContent.BuffType(), 120); - break; - - case 1: - player.AddBuff(ModContent.BuffType(), 120); - break; - - case 2: - player.AddBuff(ModContent.BuffType(), 120); - break; - - default: - break; - } + int buffType = Utils.SelectRandom(Main.rand, new int[] + { + BuffType(), + BuffType(), + BuffType() + }); + player.AddBuff(buffType, 120); } } @@ -3722,10 +3745,10 @@ namespace CalamityMod.NPCs public override bool CheckDead(NPC npc) { if (npc.lifeMax > 1000 && npc.type != 288 && - npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && + npc.type != NPCType() && + npc.type != NPCType() && + npc.type != NPCType() && + npc.type != NPCType() && npc.value > 0f && npc.HasPlayerTarget && NPC.downedMoonlord && Main.player[npc.target].ZoneDungeon) @@ -3738,19 +3761,19 @@ namespace CalamityMod.NPCs switch (randomType) { case 0: - randomType = ModContent.NPCType(); + randomType = NPCType(); break; case 1: - randomType = ModContent.NPCType(); + randomType = NPCType(); break; case 2: - randomType = ModContent.NPCType(); + randomType = NPCType(); break; case 3: - randomType = ModContent.NPCType(); + randomType = NPCType(); break; default: @@ -3846,7 +3869,7 @@ namespace CalamityMod.NPCs break; } - if (npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType()) + if (npc.type == NPCType() || npc.type == NPCType()) { if (npc.life <= npc.lifeMax * 0.25) { @@ -4027,9 +4050,9 @@ namespace CalamityMod.NPCs { PossibleEnemies = AcidRainEvent.PossibleEnemiesAS; PossibleMinibosses = AcidRainEvent.PossibleMinibossesAS; - if (!PossibleEnemies.ContainsKey(ModContent.NPCType())) + if (!PossibleEnemies.ContainsKey(NPCType())) { - PossibleEnemies.Add(ModContent.NPCType(), new AcidRainSpawnData(1, 0f, AcidRainSpawnRequirement.Anywhere)); + PossibleEnemies.Add(NPCType(), new AcidRainSpawnData(1, 0f, AcidRainSpawnRequirement.Anywhere)); } } if (CalamityWorld.downedPolterghast) @@ -4081,10 +4104,6 @@ namespace CalamityMod.NPCs } } } - if (CalamityWorld.downedPolterghast) - { - pool.Add(ModContent.NPCType(), AcidRainEvent.BloodwormSpawnRate); - } } } } @@ -4152,7 +4171,7 @@ namespace CalamityMod.NPCs { if (Main.rand.Next(5) < 4) { - int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, ModContent.DustType(), npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default, 3.5f); + int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, DustType(), npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default, 3.5f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 1.8f; Main.dust[dust].velocity.Y -= 0.5f; @@ -4169,7 +4188,7 @@ namespace CalamityMod.NPCs { if (Main.rand.Next(5) < 4) { - int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, ModContent.DustType(), npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default, 3.5f); + int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, DustType(), npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default, 3.5f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 1.8f; Main.dust[dust].velocity.Y -= 0.25f; @@ -4202,7 +4221,7 @@ namespace CalamityMod.NPCs { if (Main.rand.Next(5) < 4) { - int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, ModContent.DustType(), npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default, 3.5f); + int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, DustType(), npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default, 3.5f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 1.8f; Main.dust[dust].velocity.Y -= 0.5f; @@ -4253,7 +4272,7 @@ namespace CalamityMod.NPCs { if (Main.rand.Next(5) < 3) { - int dustType = Main.rand.NextBool(2) ? ModContent.DustType() : ModContent.DustType(); + int dustType = Main.rand.NextBool(2) ? DustType() : DustType(); int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, dustType, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default, 0.6f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 1.2f; @@ -4443,65 +4462,67 @@ namespace CalamityMod.NPCs // Damage over time debuffs if (aFlames > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/DamageOverTime/AbyssalFlames")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/AbyssalFlames")); if (astralInfection > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/DamageOverTime/AstralInfectionDebuff")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/AstralInfectionDebuff")); if (bFlames > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/DamageOverTime/BrimstoneFlames")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/BrimstoneFlames")); if (bBlood > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/DamageOverTime/BurningBlood")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/BurningBlood")); if (cDepth > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/DamageOverTime/CrushDepth")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/CrushDepth")); if (dFlames > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/DamageOverTime/DemonFlames")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/DemonFlames")); if (gsInferno > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/DamageOverTime/GodSlayerInferno")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/GodSlayerInferno")); if (hFlames > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/DamageOverTime/HolyFlames")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/HolyFlames")); if (nightwither > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/DamageOverTime/Nightwither")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/Nightwither")); if (pFlames > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/DamageOverTime/Plague")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/Plague")); if (shellfishVore > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/DamageOverTime/ShellfishEating")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/ShellfishEating")); if (pShred > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/DamageOverTime/Shred")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/Shred")); if (clamDebuff > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/DamageOverTime/SnapClamDebuff")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/SnapClamDebuff")); if (sulphurPoison > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/DamageOverTime/SulphuricPoisoning")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/SulphuricPoisoning")); if (vaporfied > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/DamageOverTime/Vaporfied")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/Vaporfied")); // Stat debuffs if (aCrunch > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/StatDebuffs/ArmorCrunch")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/ArmorCrunch")); if (enraged > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/StatDebuffs/Enraged")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/Enraged")); if (eutrophication > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/StatDebuffs/Eutrophication")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/Eutrophication")); if (eFreeze > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/StatDebuffs/ExoFreeze")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/ExoFreeze")); if (gState > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/StatDebuffs/GlacialState")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/GlacialState")); if (irradiated > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/StatDebuffs/Irradiated")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/Irradiated")); if (marked > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/StatDebuffs/MarkedforDeath")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/MarkedforDeath")); if (pearlAura > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/StatDebuffs/PearlAura")); - if (silvaStun > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/StatDebuffs/SilvaStun")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/PearlAura")); + if (relicOfResilienceWeakness > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/ProfanedWeakness")); + if (silvaStun > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/SilvaStun")); if (tSad > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/StatDebuffs/TemporalSadness")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/TemporalSadness")); if (tesla > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/StatDebuffs/TeslaFreeze")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/TeslaFreeze")); if (timeSlow > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/StatDebuffs/TimeSlow")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/TimeSlow")); if (wCleave > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/StatDebuffs/WarCleave")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/WarCleave")); if (wDeath > 0) - buffTextureList.Add(ModContent.GetTexture("CalamityMod/Buffs/StatDebuffs/WhisperingDeath")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/WhisperingDeath")); // Vanilla damage over time debuffs if (electrified > 0) @@ -4600,19 +4621,19 @@ namespace CalamityMod.NPCs if (CalamityMod.CalamityConfig.TownNPCNewShopInventoryAlertDisplay && npc.townNPC) { - if (npc.type == ModContent.NPCType() && Main.LocalPlayer.Calamity().newPermafrostInventory) + if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newPermafrostInventory) { DrawNewInventoryAlert(npc); } - else if (npc.type == ModContent.NPCType() && Main.LocalPlayer.Calamity().newCirrusInventory) + else if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newCirrusInventory) { DrawNewInventoryAlert(npc); } - else if (npc.type == ModContent.NPCType() && Main.LocalPlayer.Calamity().newAmidiasInventory) + else if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newAmidiasInventory) { DrawNewInventoryAlert(npc); } - else if (npc.type == ModContent.NPCType() && Main.LocalPlayer.Calamity().newBanditInventory) + else if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newBanditInventory) { DrawNewInventoryAlert(npc); } @@ -4713,7 +4734,7 @@ namespace CalamityMod.NPCs float drawPosY = npcHeight + npc.gfxOffY + 36f; // Texture animation variables - Texture2D texture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/NPCAlertDisplay"); + Texture2D texture = GetTexture("CalamityMod/ExtraTextures/UI/NPCAlertDisplay"); shopAlertAnimTimer++; if (shopAlertAnimTimer >= 6) { @@ -4955,10 +4976,10 @@ namespace CalamityMod.NPCs public override void GetChat(NPC npc, ref string chat) { - int fapsol = NPC.FindFirstNPC(ModContent.NPCType()); - int permadong = NPC.FindFirstNPC(ModContent.NPCType()); - int seahorse = NPC.FindFirstNPC(ModContent.NPCType()); - //int thief = NPC.FindFirstNPC(ModContent.NPCType()); + int fapsol = NPC.FindFirstNPC(NPCType()); + int permadong = NPC.FindFirstNPC(NPCType()); + int seahorse = NPC.FindFirstNPC(NPCType()); + int thief = NPC.FindFirstNPC(NPCType()); int angelstatue = NPC.FindFirstNPC(NPCID.Merchant); switch (npc.type) @@ -5002,7 +5023,7 @@ namespace CalamityMod.NPCs chat = "I don't feel very safe; I think there's pigs following me around and it frightens me."; } - if (NPC.AnyNPCs(ModContent.NPCType())) + if (NPC.AnyNPCs(NPCType())) { chat = "Sometimes, " + Main.npc[fapsol].GivenName + " just looks at me funny and I'm not sure how I feel about that."; } @@ -5010,7 +5031,7 @@ namespace CalamityMod.NPCs break; case NPCID.Angler: - if (Main.rand.NextBool(5) && NPC.AnyNPCs(ModContent.NPCType())) + if (Main.rand.NextBool(5) && NPC.AnyNPCs(NPCType())) { chat = "Someone tell " + Main.npc[seahorse].GivenName + " to quit trying to throw me out of town, it's not going to work."; } @@ -5018,7 +5039,7 @@ namespace CalamityMod.NPCs break; case NPCID.TravellingMerchant: - if (Main.rand.NextBool(5) && NPC.AnyNPCs(ModContent.NPCType()) && NPC.AnyNPCs(NPCID.Merchant)) + if (Main.rand.NextBool(5) && NPC.AnyNPCs(NPCType()) && NPC.AnyNPCs(NPCID.Merchant)) { chat = "Tell " + Main.npc[fapsol].GivenName + " I'll take up her offer and meet with her at the back of " + Main.npc[angelstatue].GivenName + "'s house."; } @@ -5084,7 +5105,7 @@ namespace CalamityMod.NPCs } if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneSnow) { - if (NPC.AnyNPCs(ModContent.NPCType()) && Main.rand.NextBool(2)) + if (NPC.AnyNPCs(NPCType()) && Main.rand.NextBool(2)) { chat = "Think " + Main.npc[permadong].GivenName + " would let me paint him like one of his French girls?!"; } @@ -5160,7 +5181,7 @@ namespace CalamityMod.NPCs chat = "That starborne illness sits upon this land like a blister. Do even more vile forces of corruption exist in worlds beyond?"; } - if (Main.rand.NextBool(5) && NPC.AnyNPCs(ModContent.NPCType()) && Main.LocalPlayer.ZoneGlowshroom) + if (Main.rand.NextBool(5) && NPC.AnyNPCs(NPCType()) && Main.LocalPlayer.ZoneGlowshroom) { chat = Main.npc[fapsol].GivenName + " put me up to this."; } @@ -5211,11 +5232,9 @@ namespace CalamityMod.NPCs break; case NPCID.GoblinTinkerer: - int banditIndex = NPC.FindFirstNPC(ModContent.NPCType()); - if (Main.rand.NextBool(3) && banditIndex != -1 && Main.LocalPlayer.Calamity().reforges >= 10) + if (Main.rand.NextBool(3) && thief != -1 && Main.LocalPlayer.Calamity().reforges >= 10) { - var thief = Main.npc[banditIndex]; - chat = $"Hey, is it just me or have my pockets gotten lighter ever since {thief.GivenName} arrived?"; + chat = $"Hey, is it just me or have my pockets gotten lighter ever since " + Main.npc[thief].GivenName + " arrived?"; } if (Main.rand.NextBool(10) && NPC.downedMoonlord) { @@ -5253,6 +5272,11 @@ namespace CalamityMod.NPCs chat = "If this acid rain keeps up, there'll be a shortage of Dirt Blocks soon enough!"; } + if (Main.rand.NextBool(7) && thief != -1) + { + chat = "I happen to have several Angel Statues at the moment, a truely rare commodity. Want one?"; + } + break; case NPCID.Mechanic: @@ -5302,12 +5326,12 @@ namespace CalamityMod.NPCs chat = "I have to thank ye again for takin' care of that sea serpent. Or was that another one..."; } - if (Main.rand.NextBool(5) && NPC.AnyNPCs(ModContent.NPCType())) + if (Main.rand.NextBool(5) && NPC.AnyNPCs(NPCType())) { chat = "I remember legends about that " + Main.npc[seahorse].GivenName + ". He ain't quite how the stories make him out to be though."; } - if (Main.rand.NextBool(5) && NPC.AnyNPCs(ModContent.NPCType())) + if (Main.rand.NextBool(5) && NPC.AnyNPCs(NPCType())) { chat = "Twenty-nine bottles of beer on the wall..."; } @@ -5468,7 +5492,7 @@ namespace CalamityMod.NPCs chat = "Devourer of what, you said? Devourer of Funds, if its payroll is anything to go by!"; } - if (Main.rand.NextBool(10) && CalamityUtils.InventoryHas(Main.LocalPlayer, ModContent.ItemType())) + if (Main.rand.NextBool(10) && CalamityUtils.InventoryHas(Main.LocalPlayer, ItemType())) { chat = "Goodness! That cane has swagger!"; } @@ -5494,18 +5518,25 @@ namespace CalamityMod.NPCs { if (type == NPCID.Merchant) { - SetShopItem(ref shop, ref nextSlot, ItemID.Flare, (Main.LocalPlayer.HasItem(ModContent.ItemType()) || Main.LocalPlayer.HasItem(ModContent.ItemType())) && !Main.LocalPlayer.HasItem(ItemID.FlareGun)); - SetShopItem(ref shop, ref nextSlot, ItemID.BlueFlare, (Main.LocalPlayer.HasItem(ModContent.ItemType()) || Main.LocalPlayer.HasItem(ModContent.ItemType())) && !Main.LocalPlayer.HasItem(ItemID.FlareGun)); + SetShopItem(ref shop, ref nextSlot, ItemID.Flare, (Main.LocalPlayer.HasItem(ItemType()) || Main.LocalPlayer.HasItem(ItemType())) && !Main.LocalPlayer.HasItem(ItemID.FlareGun)); + SetShopItem(ref shop, ref nextSlot, ItemID.BlueFlare, (Main.LocalPlayer.HasItem(ItemType()) || Main.LocalPlayer.HasItem(ItemType())) && !Main.LocalPlayer.HasItem(ItemID.FlareGun)); SetShopItem(ref shop, ref nextSlot, ItemID.ApprenticeBait, NPC.downedBoss1); SetShopItem(ref shop, ref nextSlot, ItemID.JourneymanBait, NPC.downedBoss2); SetShopItem(ref shop, ref nextSlot, WorldGen.crimson ? ItemID.Vilethorn : ItemID.CrimsonRod, WorldGen.shadowOrbSmashed || NPC.downedBoss2); SetShopItem(ref shop, ref nextSlot, WorldGen.crimson ? ItemID.BallOHurt : ItemID.TheRottedFork, WorldGen.shadowOrbSmashed || NPC.downedBoss2); SetShopItem(ref shop, ref nextSlot, ItemID.MasterBait, NPC.downedBoss3); + SetShopItem(ref shop, ref nextSlot, ItemID.AngelStatue, NPC.FindFirstNPC(NPCType()) != -1, Item.buyPrice(0, 5)); + } + + // Because of the defiled condition, the dye trader does not receive an alert icon when hardmode starts. + if (type == NPCID.DyeTrader) + { + SetShopItem(ref shop, ref nextSlot, ItemType(), Main.hardMode && CalamityWorld.defiled, Item.buyPrice(0, 10)); } if (type == NPCID.ArmsDealer) { - SetShopItem(ref shop, ref nextSlot, ItemID.Stake, Main.LocalPlayer.HasItem(ModContent.ItemType())); + SetShopItem(ref shop, ref nextSlot, ItemID.Stake, Main.LocalPlayer.HasItem(ItemType())); SetShopItem(ref shop, ref nextSlot, WorldGen.crimson ? ItemID.Musket : ItemID.TheUndertaker, WorldGen.shadowOrbSmashed || NPC.downedBoss2); SetShopItem(ref shop, ref nextSlot, ItemID.Boomstick, NPC.downedQueenBee, price: Item.buyPrice(0, 20, 0, 0)); SetShopItem(ref shop, ref nextSlot, ItemID.TacticalShotgun, NPC.downedGolemBoss, Item.buyPrice(0, 25)); @@ -5514,15 +5545,16 @@ namespace CalamityMod.NPCs if (type == NPCID.Stylist) { - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), Main.LocalPlayer.Calamity().rogueStealthMax > 0f && Main.LocalPlayer.Calamity().wearingRogueArmor); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), Main.LocalPlayer.wingTimeMax > 0); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), CalamityWorld.revenge && CalamityMod.CalamityConfig.AdrenalineAndRage); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), CalamityWorld.revenge && CalamityMod.CalamityConfig.AdrenalineAndRage); + SetShopItem(ref shop, ref nextSlot, ItemType(), Main.LocalPlayer.Calamity().rogueStealthMax > 0f && Main.LocalPlayer.Calamity().wearingRogueArmor); + SetShopItem(ref shop, ref nextSlot, ItemType(), Main.LocalPlayer.wingTimeMax > 0); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.revenge && CalamityMod.CalamityConfig.AdrenalineAndRage); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.revenge && CalamityMod.CalamityConfig.AdrenalineAndRage); } if (type == NPCID.Cyborg) { SetShopItem(ref shop, ref nextSlot, ItemID.RocketLauncher, NPC.downedGolemBoss, Item.buyPrice(0, 25)); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedPolterghast); } if (type == NPCID.Pirate) @@ -5536,41 +5568,41 @@ namespace CalamityMod.NPCs SetShopItem(ref shop, ref nextSlot, ItemID.NaturesGift, price: Item.buyPrice(0, 10)); SetShopItem(ref shop, ref nextSlot, ItemID.SlimeCrown, NPC.downedSlimeKing && CalamityMod.CalamityConfig.SellBossSummons, Item.buyPrice(0, 2)); SetShopItem(ref shop, ref nextSlot, ItemID.SuspiciousLookingEye, NPC.downedBoss1 && CalamityMod.CalamityConfig.SellBossSummons, Item.buyPrice(0, 3)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), CalamityWorld.downedCrabulon, Item.buyPrice(0, 4)); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedCrabulon, Item.buyPrice(0, 4)); SetShopItem(ref shop, ref nextSlot, ItemID.BloodySpine, NPC.downedBoss2 && CalamityMod.CalamityConfig.SellBossSummons, Item.buyPrice(0, 6)); SetShopItem(ref shop, ref nextSlot, ItemID.WormFood, NPC.downedBoss2 && CalamityMod.CalamityConfig.SellBossSummons, Item.buyPrice(0, 6)); SetShopItem(ref shop, ref nextSlot, WorldGen.crimson ? ItemID.BandofStarpower : ItemID.PanicNecklace, WorldGen.shadowOrbSmashed || NPC.downedBoss2); SetShopItem(ref shop, ref nextSlot, WorldGen.crimson ? ItemID.WormScarf : ItemID.BrainOfConfusion, Main.expertMode && NPC.downedBoss2); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), CalamityWorld.downedPerforator, Item.buyPrice(0, 10)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), CalamityWorld.downedPerforator && Main.expertMode); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), CalamityWorld.downedHiveMind, Item.buyPrice(0, 10)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), CalamityWorld.downedHiveMind && Main.expertMode); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), CalamityWorld.downedSlimeGod, Item.buyPrice(0, 15)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType()); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedPerforator, Item.buyPrice(0, 10)); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedPerforator && Main.expertMode); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedHiveMind, Item.buyPrice(0, 10)); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedHiveMind && Main.expertMode); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedSlimeGod, Item.buyPrice(0, 15)); + SetShopItem(ref shop, ref nextSlot, ItemType()); } if (type == NPCID.GoblinTinkerer) { - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(0, 5)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(0, 5)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(0, 5)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(0, 5)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(0, 5)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(1)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(0, 5)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(0, 5)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(0, 5)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(0, 5)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(0, 5)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(1)); SetShopItem(ref shop, ref nextSlot, ItemID.GoblinBattleStandard, price: Item.buyPrice(0, 1)); } if (type == NPCID.Clothier) { - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(copper: 10)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(copper: 10)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(copper: 10)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(copper: 10)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(copper: 10)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(copper: 10)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(copper: 10)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(copper: 10)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(copper: 10)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(copper: 10)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(copper: 10)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(copper: 10)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(copper: 10)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(copper: 10)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(copper: 10)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(copper: 10)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(copper: 10)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(copper: 10)); SetShopItem(ref shop, ref nextSlot, ItemID.GoldenKey, Main.hardMode, Item.buyPrice(0, 5)); SetShopItem(ref shop, ref nextSlot, ItemID.PumpkinMoonMedallion, NPC.downedHalloweenKing, Item.buyPrice(0, 25)); SetShopItem(ref shop, ref nextSlot, ItemID.NaughtyPresent, NPC.downedChristmasIceQueen, Item.buyPrice(0, 25)); @@ -5586,31 +5618,35 @@ namespace CalamityMod.NPCs SetShopItem(ref shop, ref nextSlot, ItemID.MechanicalWorm, NPC.downedMechBoss1 && CalamityMod.CalamityConfig.SellBossSummons, Item.buyPrice(0, 20)); SetShopItem(ref shop, ref nextSlot, ItemID.MechanicalEye, NPC.downedMechBoss2 && CalamityMod.CalamityConfig.SellBossSummons, Item.buyPrice(0, 20)); SetShopItem(ref shop, ref nextSlot, ItemID.MechanicalSkull, NPC.downedMechBoss3 && CalamityMod.CalamityConfig.SellBossSummons, Item.buyPrice(0, 20)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), price: Item.buyPrice(0, 0, 5)); + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(0, 0, 5)); } if (type == NPCID.Wizard) { - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), CalamityWorld.downedBrimstoneElemental, Item.buyPrice(0, 20)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), CalamityWorld.downedAstrageldon, Item.buyPrice(0, 25)); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedBrimstoneElemental, Item.buyPrice(0, 20)); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedAstrageldon, Item.buyPrice(0, 25)); SetShopItem(ref shop, ref nextSlot, ItemID.MagicMissile, price: Item.buyPrice(0, 5)); SetShopItem(ref shop, ref nextSlot, ItemID.SpectreStaff, NPC.downedGolemBoss, Item.buyPrice(0, 25)); SetShopItem(ref shop, ref nextSlot, ItemID.InfernoFork, NPC.downedGolemBoss, Item.buyPrice(0, 25)); SetShopItem(ref shop, ref nextSlot, ItemID.ShadowbeamStaff, NPC.downedGolemBoss, Item.buyPrice(0, 25)); SetShopItem(ref shop, ref nextSlot, ItemID.CelestialSigil, NPC.downedMoonlord && CalamityMod.CalamityConfig.SellBossSummons, Item.buyPrice(3)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), CalamityWorld.downedGuardians, Item.buyPrice(5)); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedGuardians, Item.buyPrice(5)); } if (type == NPCID.WitchDoctor) { + SetShopItem(ref shop, ref nextSlot, ItemType()); + SetShopItem(ref shop, ref nextSlot, ItemType()); + SetShopItem(ref shop, ref nextSlot, ItemType(), Main.hardMode); + SetShopItem(ref shop, ref nextSlot, ItemType(), Main.hardMode); SetShopItem(ref shop, ref nextSlot, ItemID.Abeemination, CalamityMod.CalamityConfig.SellBossSummons, price: Item.buyPrice(0, 8)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), NPC.downedPlantBoss && CalamityMod.CalamityConfig.SellBossSummons, Item.buyPrice(0, 20)); + SetShopItem(ref shop, ref nextSlot, ItemType(), NPC.downedPlantBoss && CalamityMod.CalamityConfig.SellBossSummons, Item.buyPrice(0, 20)); SetShopItem(ref shop, ref nextSlot, ItemID.SolarTablet, NPC.downedGolemBoss, Item.buyPrice(0, 25)); SetShopItem(ref shop, ref nextSlot, ItemID.LihzahrdPowerCell, NPC.downedGolemBoss && CalamityMod.CalamityConfig.SellBossSummons, Item.buyPrice(0, 30)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), NPC.downedGolemBoss, Item.buyPrice(0, 10)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), CalamityWorld.downedScavenger, Item.buyPrice(0, 50)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), CalamityWorld.downedPlaguebringer, Item.buyPrice(0, 50)); - SetShopItem(ref shop, ref nextSlot, ModContent.ItemType(), CalamityWorld.downedBumble, Item.buyPrice(5)); + SetShopItem(ref shop, ref nextSlot, ItemType(), NPC.downedGolemBoss, Item.buyPrice(0, 10)); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedScavenger, Item.buyPrice(0, 50)); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedPlaguebringer, Item.buyPrice(0, 50)); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedBumble, Item.buyPrice(5)); } if (type == NPCID.SkeletonMerchant) @@ -5623,7 +5659,7 @@ namespace CalamityMod.NPCs { if (Main.moonPhase == 0) { - shop[nextSlot] = ModContent.ItemType(); + shop[nextSlot] = ItemType(); nextSlot++; } } @@ -5650,19 +5686,19 @@ namespace CalamityMod.NPCs { for (int i = 0; i < types.Length; i++) { - if (types[i] == ModContent.NPCType()) + if (types[i] == NPCType()) { Main.LocalPlayer.Calamity().newPermafrostInventory = true; } - else if (types[i] == ModContent.NPCType()) + else if (types[i] == NPCType()) { Main.LocalPlayer.Calamity().newCirrusInventory = true; } - else if (types[i] == ModContent.NPCType()) + else if (types[i] == NPCType()) { Main.LocalPlayer.Calamity().newAmidiasInventory = true; } - else if (types[i] == ModContent.NPCType()) + else if (types[i] == NPCType()) { Main.LocalPlayer.Calamity().newBanditInventory = true; } @@ -5742,18 +5778,181 @@ namespace CalamityMod.NPCs for (int i = 0; i < Main.maxNPCs; i++) { if (Main.npc[i].active && Main.npc[i].type != NPCID.MartianSaucerCore && - (Main.npc[i].boss || Main.npc[i].type == NPCID.EaterofWorldsHead || Main.npc[i].type == NPCID.EaterofWorldsTail || Main.npc[i].type == ModContent.NPCType() || - Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == ModContent.NPCType())) + (Main.npc[i].boss || Main.npc[i].type == NPCID.EaterofWorldsHead || Main.npc[i].type == NPCID.EaterofWorldsTail || Main.npc[i].type == NPCType() || + Main.npc[i].type == NPCType() || Main.npc[i].type == NPCType() || Main.npc[i].type == NPCType())) { return true; } } return false; } - #endregion + #endregion - #region Any Living Players - public static bool AnyLivingPlayers() + #region Get Downed Boss Variable + public static bool GetDownedBossVariable(int type) + { + switch (type) + { + case NPCID.KingSlime: + return NPC.downedSlimeKing; + + case NPCID.EyeofCthulhu: + return NPC.downedBoss1; + + case NPCID.EaterofWorldsHead: + case NPCID.EaterofWorldsBody: + case NPCID.EaterofWorldsTail: + case NPCID.BrainofCthulhu: + return NPC.downedBoss2; + + case NPCID.QueenBee: + return NPC.downedQueenBee; + + case NPCID.SkeletronHead: + return NPC.downedBoss3; + + case NPCID.WallofFlesh: + case NPCID.WallofFleshEye: + return Main.hardMode; + + case NPCID.TheDestroyer: + case NPCID.TheDestroyerBody: + case NPCID.TheDestroyerTail: + return NPC.downedMechBoss1; + + case NPCID.Spazmatism: + case NPCID.Retinazer: + return NPC.downedMechBoss2; + + case NPCID.SkeletronPrime: + return NPC.downedMechBoss3; + + case NPCID.Plantera: + return NPC.downedPlantBoss; + + case NPCID.Golem: + case NPCID.GolemHead: + return NPC.downedGolemBoss; + + case NPCID.DukeFishron: + return NPC.downedFishron; + + case NPCID.CultistBoss: + return NPC.downedAncientCultist; + + case NPCID.MoonLordCore: + case NPCID.MoonLordHand: + case NPCID.MoonLordHead: + return NPC.downedMoonlord; + } + + if (type == NPCType() || type == NPCType() || type == NPCType()) + { + return CalamityWorld.downedDesertScourge; + } + else if (type == NPCType()) + { + return CalamityWorld.downedCrabulon; + } + else if (type == NPCType() || type == NPCType()) + { + return CalamityWorld.downedHiveMind; + } + else if (type == NPCType()) + { + return CalamityWorld.downedPerforator; + } + else if (type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType()) + { + return CalamityWorld.downedSlimeGod; + } + else if (type == NPCType()) + { + return CalamityWorld.downedCryogen; + } + else if (type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType()) + { + return CalamityWorld.downedAquaticScourge; + } + else if (type == NPCType()) + { + return CalamityWorld.downedBrimstoneElemental; + } + else if (type == NPCType() || type == NPCType()) + { + return CalamityWorld.downedCalamitas; + } + else if (type == NPCType() || type == NPCType()) + { + return CalamityWorld.downedLeviathan; + } + else if (type == NPCType()) + { + return CalamityWorld.downedAstrageldon; + } + else if (type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType()) + { + return CalamityWorld.downedStarGod; + } + else if (type == NPCType()) + { + return CalamityWorld.downedPlaguebringer; + } + else if (type == NPCType()) + { + return CalamityWorld.downedScavenger; + } + else if (type == NPCType()) + { + return CalamityWorld.downedGuardians; + } + else if (type == NPCType()) + { + return CalamityWorld.downedBumble; + } + else if (type == NPCType()) + { + return CalamityWorld.downedProvidence; + } + else if (type == NPCType() || type == NPCType() || type == NPCType()) + { + return CalamityWorld.downedSentinel1; + } + else if (type == NPCType() || type == NPCType() || type == NPCType()) + { + return CalamityWorld.downedSentinel2; + } + else if (type == NPCType()) + { + return CalamityWorld.downedSentinel3; + } + else if (type == NPCType()) + { + return CalamityWorld.downedPolterghast; + } + else if (type == NPCType()) + { + return CalamityWorld.downedBoomerDuke; + } + else if (type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType()) + { + return CalamityWorld.downedDoG; + } + else if (type == NPCType()) + { + return CalamityWorld.downedYharon; + } + else if (type == NPCType()) + { + return CalamityWorld.downedSCal; + } + + return false; + } + #endregion + + #region Any Living Players + public static bool AnyLivingPlayers() { for (int i = 0; i < Main.maxPlayers; i++) { @@ -5772,8 +5971,8 @@ namespace CalamityMod.NPCs if (target.damage > 0 && !target.boss && !target.friendly && !target.dontTakeDamage && target.type != NPCID.TheDestroyerBody && target.type != NPCID.TheDestroyerTail && target.type != NPCID.MourningWood && target.type != NPCID.Everscream && target.type != NPCID.SantaNK1 && - target.type != ModContent.NPCType() && target.type != ModContent.NPCType() && target.type != ModContent.NPCType() && - target.type != ModContent.NPCType() && target.type != ModContent.NPCType() && target.type != NPCID.DD2Betsy && !CalamityMod.enemyImmunityList.Contains(target.type) && !AcidRainEvent.AllMinibosses.Contains(target.type)) + target.type != NPCType() && target.type != NPCType() && target.type != NPCType() && + target.type != NPCType() && target.type != NPCType() && target.type != NPCID.DD2Betsy && !CalamityMod.enemyImmunityList.Contains(target.type) && !AcidRainEvent.AllMinibosses.Contains(target.type)) { return true; } diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 58127d890d..721657255b 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -272,29 +272,26 @@ namespace CalamityMod.NPCs else if (npc.type == NPCID.Golem) { DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 5, 10); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, DropHelper.RareVariantDropRateFloat); DropHelper.DropItemCondition(npc, ItemID.Picksaw, true, !NPC.downedGolemBoss); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedGolemBoss); DropHelper.DropResidentEvilAmmo(npc, NPC.downedGolemBoss, 4, 2, 1); npc.Calamity().SetNewShopVariable(new int[] { NPCID.ArmsDealer, NPCID.Cyborg, NPCID.Steampunker, NPCID.Wizard, NPCID.WitchDoctor, NPCID.DD2Bartender, ModContent.NPCType(), ModContent.NPCType() }, NPC.downedGolemBoss); - // If Golem has never been killed, send messages about PBG and Ravager + // If Golem has never been killed, send messages about PBG if (!NPC.downedGolemBoss) { string key = "Mods.CalamityMod.BabyBossText"; Color messageColor = Color.Lime; - string key2 = "Mods.CalamityMod.BabyBossText2"; - Color messageColor2 = Color.Yellow; if (Main.netMode == NetmodeID.SinglePlayer) { Main.NewText(Language.GetTextValue(key), messageColor); - Main.NewText(Language.GetTextValue(key2), messageColor2); } else if (Main.netMode == NetmodeID.Server) { NetMessage.BroadcastChatMessage(NetworkText.FromKey(key), messageColor); - NetMessage.BroadcastChatMessage(NetworkText.FromKey(key2), messageColor2); } } } @@ -1417,14 +1414,7 @@ namespace CalamityMod.NPCs break; case NPCID.GiantTortoise: - float tortoiseDropRate = Main.expertMode ? 0.2f : 0.142857f; - float shellRoll = Main.rand.NextFloat(); - bool fabledShell = shellRoll <= 0.005f; // Exact 1/200 chance for rare regardless of difficulty - if (shellRoll < tortoiseDropRate) // 1/7 (1/5 EX) chance of getting Giant Tortoise Shell OR Fabled Tortoise Shell replacing it - { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !fabledShell); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), fabledShell); - } + DropHelper.DropItemRIV(npc, ModContent.ItemType(), ModContent.ItemType(), Main.expertMode ? 0.2f : 0.142857f, 0.005f); break; case NPCID.GiantShelly: @@ -1480,18 +1470,11 @@ namespace CalamityMod.NPCs break; case NPCID.IchorSticker: - float spearDropRate = Main.expertMode ? 0.05f : 0.04f; - float spearRoll = Main.rand.NextFloat(); - bool spearOfDestiny = spearRoll <= 0.005f; // Exact 1/200 chance for rare regardless of difficulty - if (spearRoll < spearDropRate) // 1/25 (1/20 EX) chance of getting Ichor Spear OR Spear of Destiny replacing it - { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !spearOfDestiny); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), spearOfDestiny); - } + DropHelper.DropItemRIV(npc, ModContent.ItemType(), ModContent.ItemType(), Main.expertMode ? 0.05f : 0.04f, 0.005f); break; case NPCID.Harpy: - int glazeDropRate = CalamityWorld.defiled ? 20 : Main.expertMode ? 60 : 80; + int glazeDropRate = CalamityWorld.defiled ? DropHelper.DefiledDropRateInt : Main.expertMode ? 60 : 80; DropHelper.DropItemCondition(npc, ModContent.ItemType(), NPC.downedBoss1, glazeDropRate, 1, 1); DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.hardMode && !npc.SpawnedFromStatue, Main.expertMode ? 2 : 3, 1, 1); break; @@ -1539,14 +1522,7 @@ namespace CalamityMod.NPCs break; case NPCID.PirateCrossbower: - float crossbowDropRate = Main.expertMode ? 0.05f : 0.04f; - float arbalestRoll = Main.rand.NextFloat(); - bool arbalest = arbalestRoll <= 0.005f; // Exact 1/200 chance for rare regardless of difficulty - if (arbalestRoll < crossbowDropRate) // 1/25 (1/20 EX) chance of getting Raider's Glory OR Arbalest replacing it - { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !arbalest); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), arbalest); - } + DropHelper.DropItemRIV(npc, ModContent.ItemType(), ModContent.ItemType(), Main.expertMode ? 0.05f : 0.04f, 0.005f); break; case NPCID.GoblinSummoner: @@ -1765,6 +1741,7 @@ namespace CalamityMod.NPCs break; case NPCID.QueenBee: + DropHelper.DropItemCondition(npc, ItemID.Stinger, !Main.expertMode, 5, 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 30, 50); break; @@ -1852,6 +1829,12 @@ namespace CalamityMod.NPCs { DropHelper.DropItemChance(npc, ModContent.ItemType(), 2, 1, Main.expertMode ? 3 : 1); } + + // Every type of moss hornet can drop stingers + if (CalamityMod.mossHornetList.Contains(npc.type)) + { + DropHelper.DropItemChance(npc, ItemID.Stinger, Main.expertMode ? 1f : 0.6666f); + } } #endregion diff --git a/NPCs/CeaselessVoid/CeaselessVoid.cs b/NPCs/CeaselessVoid/CeaselessVoid.cs index 6fda92343c..470e72f160 100644 --- a/NPCs/CeaselessVoid/CeaselessVoid.cs +++ b/NPCs/CeaselessVoid/CeaselessVoid.cs @@ -139,13 +139,7 @@ namespace CalamityMod.NPCs.CeaselessVoid DropHelper.DropItemChance(npc, ModContent.ItemType(), Main.expertMode ? 3 : 4); // Equipment - float f = Main.rand.NextFloat(); - bool replaceWithRare = f <= DropHelper.RareVariantDropRateFloat; // 1/40 chance overall of getting The Evolution - if (f < 0.2f) // 1/5 chance of getting Arcanum of the Void OR The Evolution replacing it - { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !replaceWithRare); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), replaceWithRare); - } + DropHelper.DropItemRIV(npc, ModContent.ItemType(), ModContent.ItemType(), 0.2f, DropHelper.RareVariantDropRateFloat); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); diff --git a/NPCs/CeaselessVoid/DarkEnergy.cs b/NPCs/CeaselessVoid/DarkEnergy.cs index 7a40c439f2..8d950437c8 100644 --- a/NPCs/CeaselessVoid/DarkEnergy.cs +++ b/NPCs/CeaselessVoid/DarkEnergy.cs @@ -264,7 +264,7 @@ namespace CalamityMod.NPCs.CeaselessVoid public override bool CheckActive() { - return false; + return CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active; } public override void OnHitByProjectile(Projectile projectile, int damage, float knockback, bool crit) diff --git a/NPCs/CeaselessVoid/DarkEnergy2.cs b/NPCs/CeaselessVoid/DarkEnergy2.cs index 237afdd54d..d8a50f1e32 100644 --- a/NPCs/CeaselessVoid/DarkEnergy2.cs +++ b/NPCs/CeaselessVoid/DarkEnergy2.cs @@ -221,7 +221,7 @@ namespace CalamityMod.NPCs.CeaselessVoid public override bool CheckActive() { - return false; + return CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active; } public override void OnHitByProjectile(Projectile projectile, int damage, float knockback, bool crit) diff --git a/NPCs/CeaselessVoid/DarkEnergy3.cs b/NPCs/CeaselessVoid/DarkEnergy3.cs index 1763a24bf1..4288c4e321 100644 --- a/NPCs/CeaselessVoid/DarkEnergy3.cs +++ b/NPCs/CeaselessVoid/DarkEnergy3.cs @@ -249,7 +249,7 @@ namespace CalamityMod.NPCs.CeaselessVoid public override bool CheckActive() { - return false; + return CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active; } public override void OnHitByProjectile(Projectile projectile, int damage, float knockback, bool crit) diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index de1ddf84f8..830a1f5fed 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -1,4 +1,5 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; @@ -23,7 +24,6 @@ using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; using Terraria.ModLoader.Config; -using CalamityMod; namespace CalamityMod.NPCs.Cryogen { [AutoloadBossHead] @@ -167,12 +167,9 @@ namespace CalamityMod.NPCs.Cryogen npc.rotation = npc.velocity.X * 0.1f; } - if (!Main.raining && !CalamityWorld.bossRushActive) - { - CalamityUtils.StartRain(); - } + CalamityMod.StopRain(); - if (!player.active || player.dead) + if (!player.active || player.dead) { npc.TargetClosest(false); player = Main.player[npc.target]; @@ -732,6 +729,25 @@ namespace CalamityMod.NPCs.Cryogen teleportLocationX = 0; iceShard = 0; npc.netUpdate = true; + + int chance = 100; + if (DateTime.Now.Month == 4 && DateTime.Now.Day == 1) + { + chance = 20; + } + if (Main.rand.NextBool(chance)) + { + string key = "Mods.CalamityMod.CryogenBossText"; + Color messageColor = Color.Cyan; + if (Main.netMode == NetmodeID.SinglePlayer) + { + Main.NewText(Language.GetTextValue(key), messageColor); + } + else if (Main.netMode == NetmodeID.Server) + { + NetMessage.BroadcastChatMessage(NetworkText.FromKey(key), messageColor); + } + } } } else if (npc.ai[0] == 5f) diff --git a/NPCs/Cryogen/CryogenIce.cs b/NPCs/Cryogen/CryogenIce.cs index 8064b30814..95e383fc06 100644 --- a/NPCs/Cryogen/CryogenIce.cs +++ b/NPCs/Cryogen/CryogenIce.cs @@ -37,12 +37,12 @@ namespace CalamityMod.NPCs.Cryogen public override void AI() { - npc.alpha -= 3; + npc.alpha -= 3; if (npc.alpha < 0) - { npc.alpha = 0; - } + npc.rotation += 0.15f; + if (npc.type == ModContent.NPCType()) { int num989 = (int)npc.ai[0]; @@ -52,7 +52,7 @@ namespace CalamityMod.NPCs.Cryogen npc.position = Main.npc[num989].Center; npc.position.X = npc.position.X - (float)(npc.width / 2); npc.position.Y = npc.position.Y - (float)(npc.height / 2); - npc.gfxOffY = Main.npc[num989].gfxOffY; + npc.gfxOffY = Main.npc[num989].gfxOffY + 14; return; } npc.life = 0; diff --git a/NPCs/Cryogen/IceMass.cs b/NPCs/Cryogen/IceMass.cs index ea66820ec8..2680500612 100644 --- a/NPCs/Cryogen/IceMass.cs +++ b/NPCs/Cryogen/IceMass.cs @@ -1,4 +1,5 @@ using CalamityMod.World; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,7 +11,7 @@ namespace CalamityMod.NPCs.Cryogen public override void SetStaticDefaults() { DisplayName.SetDefault("Aurora Spirit"); - Main.npcFrameCount[npc.type] = 6; + Main.npcFrameCount[npc.type] = 5; } public override void SetDefaults() @@ -27,13 +28,40 @@ namespace CalamityMod.NPCs.Cryogen npc.lifeMax = 30000; } npc.knockBackResist = 0f; - animationType = 472; npc.canGhostHeal = false; npc.HitSound = SoundID.NPCHit5; npc.DeathSound = SoundID.NPCDeath15; npc.coldDamage = true; } + public override void FindFrame(int frameHeight) + { + int num1 = 1; + if (!Main.dedServ) + { + if (!Main.NPCLoaded[npc.type] || Main.npcTexture[npc.type] == null) + return; + num1 = Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type]; + } + if (npc.velocity.X < 0f) + npc.direction = -1; + else + npc.direction = 1; + if (npc.direction == 1) + npc.spriteDirection = 1; + if (npc.direction == -1) + npc.spriteDirection = -1; + npc.rotation = (float)Math.Atan2((double)npc.velocity.Y * (double)npc.direction, (double)npc.velocity.X * (double)npc.direction); + npc.frameCounter++; + if (npc.frameCounter > 4) + { + npc.frame.Y += num1; + npc.frameCounter = 0; + } + if (npc.frame.Y / num1 >= Main.npcFrameCount[npc.type]) + npc.frame.Y = 0; + } + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(BuffID.Frostburn, 90, true); diff --git a/NPCs/Cryogen/IceMass.png b/NPCs/Cryogen/IceMass.png index 894d997568..f85f260eba 100644 Binary files a/NPCs/Cryogen/IceMass.png and b/NPCs/Cryogen/IceMass.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadS.cs b/NPCs/DevourerofGods/DevourerofGodsHeadS.cs index e13dca68ca..c19edecb2a 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHeadS.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHeadS.cs @@ -1041,6 +1041,9 @@ namespace CalamityMod.NPCs.DevourerofGods public override void NPCLoot() { + // Stop the countdown -- if you kill DoG in less than 60 frames, this will stop another one from spawning. + CalamityWorld.DoGSecondStageCountdown = 0; + DropHelper.DropBags(npc); DropHelper.DropItem(npc, ModContent.ItemType(), 8, 14); diff --git a/NPCs/NormalNPCs/ArmoredDiggerHead.cs b/NPCs/NormalNPCs/ArmoredDiggerHead.cs index e2764b7929..fbd2da14f3 100644 --- a/NPCs/NormalNPCs/ArmoredDiggerHead.cs +++ b/NPCs/NormalNPCs/ArmoredDiggerHead.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.SummonItems; -using CalamityMod.Items.Weapons.Ranged; using CalamityMod.World; using Microsoft.Xna.Framework; using System; @@ -423,7 +422,6 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItemChance(npc, ModContent.ItemType(), DropHelper.RareVariantDropRateInt); DropHelper.DropItemChance(npc, ModContent.ItemType(), 3); DropHelper.DropItem(npc, ModContent.ItemType(), 2, 4); } diff --git a/NPCs/NormalNPCs/Cnidrion.cs b/NPCs/NormalNPCs/Cnidrion.cs index aee58dc0e3..d49b9e1c89 100644 --- a/NPCs/NormalNPCs/Cnidrion.cs +++ b/NPCs/NormalNPCs/Cnidrion.cs @@ -295,17 +295,11 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Coral, Main.rand.Next(1, 4)); - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Starfish, Main.rand.Next(1, 4)); - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Seashell, Main.rand.Next(1, 4)); - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ModContent.ItemType(), Main.rand.Next(1, 4)); - if (Main.rand.NextBool(4)) - { - if (Main.rand.NextBool(25)) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ModContent.ItemType()); - else - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ModContent.ItemType()); - } + DropHelper.DropItem(npc, ItemID.Coral, 1, 3); + DropHelper.DropItem(npc, ItemID.Starfish, 1, 3); + DropHelper.DropItem(npc, ItemID.Seashell, 1, 3); + DropHelper.DropItem(npc, ModContent.ItemType(), 1, 3); + DropHelper.DropItemRIV(npc, ModContent.ItemType(), ModContent.ItemType(), 0.25f, 0.01f); } } } diff --git a/NPCs/NormalNPCs/Eidolist.cs b/NPCs/NormalNPCs/Eidolist.cs index de6d14ce7a..014d2d13dd 100644 --- a/NPCs/NormalNPCs/Eidolist.cs +++ b/NPCs/NormalNPCs/Eidolist.cs @@ -62,7 +62,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0f, 0.4f, 0.5f); + Lighting.AddLight((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f), 0f, 0.4f, 0.5f); if (npc.justHit) { hasBeenHit = true; @@ -92,7 +92,7 @@ namespace CalamityMod.NPCs.NormalNPCs npc.localAI[2] = 1f; } } - npc.velocity.X = npc.velocity.X + (float)npc.direction * 0.1f; + npc.velocity.X += npc.direction * 0.1f; if (npc.velocity.X < -2f || npc.velocity.X > 2f) { npc.velocity.X = npc.velocity.X * 0.95f; @@ -100,7 +100,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (npc.localAI[2] == -1f) { npc.velocity.Y = npc.velocity.Y - 0.01f; - if ((double)npc.velocity.Y < -0.3) + if (npc.velocity.Y < -0.3f) { npc.localAI[2] = 1f; } @@ -108,27 +108,26 @@ namespace CalamityMod.NPCs.NormalNPCs else { npc.velocity.Y = npc.velocity.Y + 0.01f; - if ((double)npc.velocity.Y > 0.3) + if (npc.velocity.Y > 0.3f) { npc.localAI[2] = -1f; } } - if ((double)npc.velocity.Y > 0.4 || (double)npc.velocity.Y < -0.4) + if (npc.velocity.Y > 0.4f || npc.velocity.Y < -0.4f) { - npc.velocity.Y = npc.velocity.Y * 0.95f; + npc.velocity.Y *= 0.95f; } return; } npc.noTileCollide = true; float num1446 = 7f; - int num1447 = 480; - float num244; + float num1447 = 480f; if (npc.localAI[1] == 1f) { npc.localAI[1] = 0f; if (Main.rand.NextBool(4)) { - npc.ai[0] = (float)num1447; + npc.ai[0] = num1447; } } npc.TargetClosest(true); @@ -144,22 +143,18 @@ namespace CalamityMod.NPCs.NormalNPCs if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { float speed = 5f; - Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)(npc.height / 2)); - float num6 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector.X + (float)Main.rand.Next(-10, 11); - float num7 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector.Y + (float)Main.rand.Next(-10, 11); - float num8 = (float)Math.Sqrt((double)(num6 * num6 + num7 * num7)); - num8 = speed / num8; - num6 *= num8; - num7 *= num8; - int damage = 40; - if (Main.expertMode) + Vector2 vector = new Vector2(npc.Center.X, npc.Center.Y); + float xDist = Main.player[npc.target].Center.X - vector.X + Main.rand.NextFloat(-10f, 10f); + float yDist = Main.player[npc.target].Center.Y - vector.Y + Main.rand.NextFloat(-10f, 10f); + Vector2 targetVec = new Vector2(yDist, yDist); + float targetDist = targetVec.Length(); + targetDist = speed / targetDist; + targetVec.X *= targetDist; + targetVec.Y *= targetDist; + int damage = Main.expertMode ? 30 : 40; + if (Main.rand.NextBool(2)) { - damage = 30; - } - int random = Main.rand.Next(2); - if (random == 0) - { - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, num6, num7, 465, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.Center, targetVec, ProjectileID.CultistBossLightningOrb, damage, 0f, Main.myPlayer, 0f, 0f); } else { @@ -172,7 +167,7 @@ namespace CalamityMod.NPCs.NormalNPCs for (int n = 0; n < 1; n++) { Vector2 vector4 = vec * 4f; - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector4.X, vector4.Y, 464, damage, 0f, Main.myPlayer, 0f, 1f); + Projectile.NewProjectile(npc.Center, vector4, ProjectileID.CultistBossIceMist, damage, 0f, Main.myPlayer, 0f, 1f); } } } @@ -195,36 +190,30 @@ namespace CalamityMod.NPCs.NormalNPCs if (npc.ai[2] != 0f && npc.ai[3] != 0f) { Main.PlaySound(SoundID.Item8, npc.Center); - int num; - for (int num1449 = 0; num1449 < 20; num1449 = num + 1) + for (int num1449 = 0; num1449 < 20; num1449++) { int num1450 = Dust.NewDust(npc.position, npc.width, npc.height, 20, 0f, 0f, 100, Color.Transparent, 1f); Dust dust = Main.dust[num1450]; dust.velocity *= 3f; - Main.dust[num1450].noGravity = true; - Main.dust[num1450].scale = 2.5f; - num = num1449; + dust.noGravity = true; + dust.scale = 2.5f; } npc.Center = new Vector2(npc.ai[2] * 16f, npc.ai[3] * 16f); npc.velocity = Vector2.Zero; npc.ai[2] = 0f; npc.ai[3] = 0f; Main.PlaySound(SoundID.Item8, npc.Center); - for (int num1451 = 0; num1451 < 20; num1451 = num + 1) + for (int num1451 = 0; num1451 < 20; num1451++) { int num1452 = Dust.NewDust(npc.position, npc.width, npc.height, 20, 0f, 0f, 100, Color.Transparent, 1f); Dust dust = Main.dust[num1452]; dust.velocity *= 3f; - Main.dust[num1452].noGravity = true; - Main.dust[num1452].scale = 2.5f; - num = num1451; + dust.noGravity = true; + dust.scale = 2.5f; } } - float[] var_9_48E3C_cp_0 = npc.ai; - int var_9_48E3C_cp_1 = 0; - num244 = var_9_48E3C_cp_0[var_9_48E3C_cp_1]; - var_9_48E3C_cp_0[var_9_48E3C_cp_1] = num244 + 1f; - if (npc.ai[0] >= (float)num1447 && Main.netMode != NetmodeID.MultiplayerClient) + npc.ai[0] += 1f; + if (npc.ai[0] >= num1447 && Main.netMode != NetmodeID.MultiplayerClient) { npc.ai[0] = 0f; Point point12 = npc.Center.ToTileCoordinates(); @@ -286,7 +275,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (!Main.hardMode) + if (!Main.hardMode || NPC.AnyNPCs(ModContent.NPCType())) { return 0f; } @@ -314,30 +303,15 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - if (Main.rand.NextBool(4)) - { - if (!NPC.LunarApocalypseIsUp) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ModContent.ItemType()); - } - } if (Main.rand.NextBool(10)) { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.BlueLunaticHood); - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.BlueLunaticRobe); + DropHelper.DropItem(npc, ItemID.BlueLunaticHood); + DropHelper.DropItem(npc, ItemID.BlueLunaticRobe); } - if (CalamityWorld.downedCalamitas) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ModContent.ItemType(), Main.rand.Next(8, 11)); - if (Main.expertMode && Main.rand.NextBool(2)) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ModContent.ItemType(), Main.rand.Next(2, 5)); - } - } - if (NPC.downedPlantBoss) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Ectoplasm, Main.rand.Next(3, 6)); - } + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !NPC.LunarApocalypseIsUp, 0.25f); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 1f, 8, 10); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 0.5f, 2, 4); + DropHelper.DropItemCondition(npc, ItemID.Ectoplasm, NPC.downedPlantBoss, 1f, 3, 5); } } } diff --git a/NPCs/NormalNPCs/KingSlimeJewel.cs b/NPCs/NormalNPCs/KingSlimeJewel.cs index 78b6cf286e..d5e7e1dd12 100644 --- a/NPCs/NormalNPCs/KingSlimeJewel.cs +++ b/NPCs/NormalNPCs/KingSlimeJewel.cs @@ -1,4 +1,5 @@ -using CalamityMod.World; +using CalamityMod.Projectiles.Boss; +using CalamityMod.World; using Microsoft.Xna.Framework; using System; using Terraria; @@ -106,42 +107,40 @@ namespace CalamityMod.NPCs.NormalNPCs { npc.localAI[0] = 0f; - Vector2 vector62 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num506 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector62.X; - float num507 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector62.Y; - float num508 = (float)Math.Sqrt((double)(num506 * num506 + num507 * num507)); + Vector2 npcPos = new Vector2(npc.Center.X, npc.Center.Y); + float xDist = Main.player[npc.target].Center.X - npcPos.X; + float yDist = Main.player[npc.target].Center.Y - npcPos.Y; + Vector2 projVector = new Vector2(xDist, yDist); + float projLength = projVector.Length(); - float num509 = CalamityWorld.bossRushActive ? 18f : 9f; - int num510 = 11; + float speed = CalamityWorld.bossRushActive ? 18f : 9f; + int damage = 11; if (CalamityWorld.death) - num510 += 1; - int num511 = ProjectileID.RubyBolt; + damage += 1; + int type = ModContent.ProjectileType(); - num508 = num509 / num508; - num506 *= num508; - num507 *= num508; - vector62.X += num506 * 2f; - vector62.Y += num507 * 2f; + projLength = speed / projLength; + projVector.X *= projLength; + projVector.Y *= projLength; + npcPos.X += projVector.X * 2f; + npcPos.Y += projVector.Y * 2f; - for (int num621 = 0; num621 < 10; num621++) + for (int dusty = 0; dusty < 10; dusty++) { - Vector2 velocity2 = new Vector2(num506, num507); - velocity2.Normalize(); - int num622 = Dust.NewDust(npc.Center, npc.width, npc.height, 90, velocity2.X, velocity2.Y, 100, default, 2f); - Main.dust[num622].velocity *= 1.5f; - Main.dust[num622].noGravity = true; + Vector2 dustVel = projVector; + dustVel.Normalize(); + int ruby = Dust.NewDust(npc.Center, npc.width, npc.height, 90, dustVel.X, dustVel.Y, 100, default, 2f); + Main.dust[ruby].velocity *= 1.5f; + Main.dust[ruby].noGravity = true; if (Main.rand.NextBool(2)) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[ruby].scale = 0.5f; + Main.dust[ruby].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 8); - int proj = Projectile.NewProjectile(vector62.X, vector62.Y, num506, num507, num511, num510, 0f, Main.myPlayer, 0f, 0f); - // Protection against projectile cap - if(proj < Main.maxProjectiles) - Main.projectile[proj].Calamity().forceHostile = true; + int proj = Projectile.NewProjectile(npcPos, projVector, type, damage, 0f, Main.myPlayer, 0f, 0f); } } } diff --git a/NPCs/NormalNPCs/PlagueBee.cs b/NPCs/NormalNPCs/PlagueBee.cs index e072189a1b..10f5f879dd 100644 --- a/NPCs/NormalNPCs/PlagueBee.cs +++ b/NPCs/NormalNPCs/PlagueBee.cs @@ -101,7 +101,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ModContent.ItemType(), Main.rand.Next(1, 3)); + DropHelper.DropItemChance(npc, ItemID.Stinger, Main.expertMode ? 0.5f : 0.25f); + DropHelper.DropItem(npc, ModContent.ItemType(), 1, 2); } public override float SpawnChance(NPCSpawnInfo spawnInfo) diff --git a/NPCs/NormalNPCs/PlagueBeeLarge.cs b/NPCs/NormalNPCs/PlagueBeeLarge.cs index f7ded6f32e..c1c9c01b83 100644 --- a/NPCs/NormalNPCs/PlagueBeeLarge.cs +++ b/NPCs/NormalNPCs/PlagueBeeLarge.cs @@ -100,7 +100,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ModContent.ItemType(), Main.rand.Next(2, 4)); + DropHelper.DropItemChance(npc, ItemID.Stinger, Main.expertMode ? 0.5f : 0.25f); + DropHelper.DropItem(npc, ModContent.ItemType(), 2, 3); } public override float SpawnChance(NPCSpawnInfo spawnInfo) diff --git a/NPCs/NormalNPCs/PlaguedJungleSlime.cs b/NPCs/NormalNPCs/PlaguedJungleSlime.cs index 59fac63837..8651394bcb 100644 --- a/NPCs/NormalNPCs/PlaguedJungleSlime.cs +++ b/NPCs/NormalNPCs/PlaguedJungleSlime.cs @@ -128,7 +128,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ModContent.ItemType(), Main.rand.Next(1, 3)); + DropHelper.DropItemChance(npc, ItemID.Stinger, Main.expertMode ? 0.5f : 0.25f); + DropHelper.DropItem(npc, ModContent.ItemType(), 1, 2); } public override void OnHitPlayer(Player player, int damage, bool crit) diff --git a/NPCs/NormalNPCs/ProfanedEnergyLantern.cs b/NPCs/NormalNPCs/ProfanedEnergyLantern.cs index 75a87f295f..940d89409f 100644 --- a/NPCs/NormalNPCs/ProfanedEnergyLantern.cs +++ b/NPCs/NormalNPCs/ProfanedEnergyLantern.cs @@ -211,9 +211,10 @@ namespace CalamityMod.NPCs.NormalNPCs drawPositionY = Main.npc[CalamityGlobalNPC.energyFlame].Center.Y - center.Y; drawPositionY -= 10f; Color color = Lighting.GetColor((int)center.X / 16, (int)(center.Y / 16f)); - Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/NormalNPCs/ProfanedEnergySegment"), new Vector2(center.X - Main.screenPosition.X, center.Y - Main.screenPosition.Y), - new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, 0, ModContent.GetTexture("CalamityMod/NPCs/NormalNPCs/ProfanedEnergySegment").Width, ModContent.GetTexture("CalamityMod/NPCs/NormalNPCs/ProfanedEnergySegment").Height)), color, rotation, - new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/NormalNPCs/ProfanedEnergySegment").Width * 0.5f, (float)ModContent.GetTexture("CalamityMod/NPCs/NormalNPCs/ProfanedEnergySegment").Height * 0.5f), 1f, SpriteEffects.None, 0f); + Texture2D chain = ModContent.GetTexture("CalamityMod/NPCs/NormalNPCs/ProfanedEnergySegment"); + Main.spriteBatch.Draw(chain, new Vector2(center.X - Main.screenPosition.X, center.Y - Main.screenPosition.Y), + new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, 0, chain.Width, chain.Height)), color, rotation, + new Vector2((float)chain.Width * 0.5f, (float)chain.Height * 0.5f), 1f, SpriteEffects.None, 0f); } } } diff --git a/NPCs/NormalNPCs/ShockstormShuttle.cs b/NPCs/NormalNPCs/ShockstormShuttle.cs index 5a71dd141c..a3a866540a 100644 --- a/NPCs/NormalNPCs/ShockstormShuttle.cs +++ b/NPCs/NormalNPCs/ShockstormShuttle.cs @@ -61,10 +61,10 @@ namespace CalamityMod.NPCs.NormalNPCs { num184 = 22; } - int num185 = 435; //projectile ID + int num185 = ProjectileID.MartianTurretBolt; //projectile ID if (Main.rand.NextBool(8)) { - num185 = 449; //more powerful projectile ID + num185 = ProjectileID.SaucerLaser; //more powerful projectile ID } value9.X += num180; value9.Y += num182; @@ -457,7 +457,7 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - int num185 = 449; + int num185 = ProjectileID.SaucerLaser; value9.X += num180; value9.Y += num182; for (int num186 = 0; num186 < 2; num186++) diff --git a/NPCs/Perforator/PerforatorCyst.cs b/NPCs/Perforator/PerforatorCyst.cs index b168dd21ae..049bc41fbe 100644 --- a/NPCs/Perforator/PerforatorCyst.cs +++ b/NPCs/Perforator/PerforatorCyst.cs @@ -22,7 +22,7 @@ namespace CalamityMod.NPCs.Perforator aiType = -1; npc.damage = 0; npc.width = 30; //324 - npc.height = 30; //216 + npc.height = 26; //216 npc.defense = 0; npc.lifeMax = 1000; npc.knockBackResist = 0f; diff --git a/NPCs/Perforator/PerforatorCyst.png b/NPCs/Perforator/PerforatorCyst.png index 718dddd872..34a7b4997d 100644 Binary files a/NPCs/Perforator/PerforatorCyst.png and b/NPCs/Perforator/PerforatorCyst.png differ diff --git a/NPCs/Perforator/PerforatorCystGlow.png b/NPCs/Perforator/PerforatorCystGlow.png index 1d107bc654..ad3d4d78c2 100644 Binary files a/NPCs/Perforator/PerforatorCystGlow.png and b/NPCs/Perforator/PerforatorCystGlow.png differ diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs index 5c5f9c4319..12830e52c8 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs @@ -974,10 +974,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath } } - public override bool CheckActive() - { - return canDespawn; - } + public override bool CheckActive() => canDespawn; public override void HitEffect(int hitDirection, double damage) { @@ -1134,6 +1131,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { // Materials DropHelper.DropItemSpray(npc, ModContent.ItemType(), 10, 14); + DropHelper.DropItemSpray(npc, ItemID.Stinger, 3, 5); // Weapons DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); // Virulence diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerShade.cs b/NPCs/PlaguebringerGoliath/PlaguebringerShade.cs index 68b5ca4ec2..8a4a6b5cbb 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerShade.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerShade.cs @@ -673,11 +673,14 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath } } + public override bool PreNPCLoot() => !NPC.AnyNPCs(ModContent.NPCType()); //don't drop items in the PBG fight + public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType(), 8, 12); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 50); //no, this isn't getting boosted by Defiled. Rover, I don't care. PBG also drops it + DropHelper.DropItemChance(npc, ItemID.Stinger, Main.expertMode ? 0.5f : 0.25f, 2, 3); + DropHelper.DropItem(npc, ModContent.ItemType(), 8, 12); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 50); //no, this isn't getting boosted by Defiled. Rover, I don't care. PBG also drops it } public override void OnHitPlayer(Player player, int damage, bool crit) diff --git a/NPCs/Polterghast/Polterghast.cs b/NPCs/Polterghast/Polterghast.cs index 775ca97e0a..7a8b222ab1 100644 --- a/NPCs/Polterghast/Polterghast.cs +++ b/NPCs/Polterghast/Polterghast.cs @@ -1,4 +1,5 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; using CalamityMod.Items.Armor.Vanity; @@ -23,7 +24,6 @@ using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; using Terraria.ModLoader.Config; -using CalamityMod; namespace CalamityMod.NPCs.Polterghast { [AutoloadBossHead] @@ -104,7 +104,7 @@ namespace CalamityMod.NPCs.Polterghast public override void AI() { // Emit light - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.1f, 0.5f, 0.5f); + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.1f, 0.5f, 0.5f); // whoAmI variable CalamityGlobalNPC.ghostBoss = npc.whoAmI; @@ -121,10 +121,10 @@ namespace CalamityMod.NPCs.Polterghast 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 * (death ? 0.9 : 0.75); //hooks fire beams - bool phase3 = (double)npc.life < (double)npc.lifeMax * (revenge ? (death ? 0.8 : 0.5) : 0.33); //hooks stop shooting and polter begins charging with ghosts spinning around player - bool phase4 = (double)npc.life < (double)npc.lifeMax * (revenge ? (death ? 0.5 : 0.33) : 0.2); //starts spitting ghost dudes - bool phase5 = (double)npc.life < (double)npc.lifeMax * (revenge ? (death ? 0.25 : 0.1) : 0.05); //starts moving incredibly fast + bool phase2 = npc.life < npc.lifeMax * (death ? 0.9 : 0.75); //hooks fire beams + bool phase3 = npc.life < npc.lifeMax * (revenge ? (death ? 0.8 : 0.5) : 0.33); //hooks stop shooting and polter begins charging with ghosts spinning around player + bool phase4 = npc.life < npc.lifeMax * (revenge ? (death ? 0.5 : 0.33) : 0.2); //starts spitting ghost dudes + bool phase5 = npc.life < npc.lifeMax * (revenge ? (death ? 0.25 : 0.1) : 0.05); //starts moving incredibly fast // Target npc.TargetClosest(true); @@ -176,15 +176,15 @@ namespace CalamityMod.NPCs.Polterghast } num = num733; } - num730 /= (float)num732; - num731 /= (float)num732; + num730 /= num732; + num731 /= num732; // Velocity and acceleration bool charging = npc.ai[2] >= 300f; bool reset = npc.ai[2] >= 600f; float num734 = 2.5f; float num735 = 0.025f; - if (!player.ZoneDungeon && !CalamityWorld.bossRushActive && (double)player.position.Y < Main.worldSurface * 16.0) + if (!player.ZoneDungeon && !CalamityWorld.bossRushActive && player.position.Y < Main.worldSurface * 16.0) { despawnTimer--; if (despawnTimer <= 0) @@ -283,16 +283,16 @@ namespace CalamityMod.NPCs.Polterghast num734 += 10f; } - float num738 = (float)Math.Sqrt((double)(num736 * num736 + num737 * num737)); + float num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); int num739 = 500; if (speedBoost) num739 += 250; if (expertMode) num739 += 150; - if (num738 >= (float)num739) + if (num738 >= num739) { - num738 = (float)num739 / num738; + num738 = num739 / num738; num736 *= num738; num737 *= num738; } @@ -302,7 +302,7 @@ namespace CalamityMod.NPCs.Polterghast vector91 = new Vector2(vector.X, vector.Y); num736 = num730 - vector91.X; num737 = num731 - vector91.Y; - num738 = (float)Math.Sqrt((double)(num736 * num736 + num737 * num737)); + num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); if (num738 < num734) { @@ -319,7 +319,7 @@ namespace CalamityMod.NPCs.Polterghast Vector2 vector92 = new Vector2(vector.X, vector.Y); float num740 = player.Center.X - vector92.X; float num741 = player.Center.Y - vector92.Y; - npc.rotation = (float)Math.Atan2((double)num741, (double)num740) + 1.57f; + npc.rotation = (float)Math.Atan2(num741, num740) + MathHelper.PiOver2; if (npc.velocity.X < num736) { @@ -381,9 +381,9 @@ namespace CalamityMod.NPCs.Polterghast num742 *= 2f; Vector2 vector93 = new Vector2(vector.X, vector.Y); - float num743 = player.position.X + (float)player.width * 0.5f - vector93.X; - float num744 = player.position.Y + (float)player.height * 0.5f - vector93.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num743 = player.position.X + player.width * 0.5f - vector93.X; + float num744 = player.position.Y + player.height * 0.5f - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; @@ -415,9 +415,9 @@ namespace CalamityMod.NPCs.Polterghast num742 *= 2f; Vector2 vector93 = new Vector2(vector.X, vector.Y); - float num743 = player.position.X + (float)player.width * 0.5f - vector93.X; - float num744 = player.position.Y + (float)player.height * 0.5f - vector93.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num743 = player.position.X + player.width * 0.5f - vector93.X; + float num744 = player.position.Y + player.height * 0.5f - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; @@ -459,7 +459,7 @@ namespace CalamityMod.NPCs.Polterghast if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 30; num623++) @@ -474,8 +474,8 @@ namespace CalamityMod.NPCs.Polterghast npc.GivenName = "Necroghast"; - npc.damage = (int)((float)npc.defDamage * 1.2f); - npc.defense = (int)((float)npc.defDefense * 0.8f); + npc.damage = (int)(npc.defDamage * 1.2f); + npc.defense = (int)(npc.defDefense * 0.8f); if (speedBoost || npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) { @@ -507,9 +507,9 @@ namespace CalamityMod.NPCs.Polterghast num742 *= 2f; Vector2 vector93 = new Vector2(vector.X, vector.Y); - float num743 = player.position.X + (float)player.width * 0.5f - vector93.X; - float num744 = player.position.Y + (float)player.height * 0.5f - vector93.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num743 = player.position.X + player.width * 0.5f - vector93.X; + float num744 = player.position.Y + player.height * 0.5f - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; @@ -541,9 +541,9 @@ namespace CalamityMod.NPCs.Polterghast num742 *= 2f; Vector2 vector93 = new Vector2(vector.X, vector.Y); - float num743 = player.position.X + (float)player.width * 0.5f - vector93.X; - float num744 = player.position.Y + (float)player.height * 0.5f - vector93.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num743 = player.position.X + player.width * 0.5f - vector93.X; + float num744 = player.position.Y + player.height * 0.5f - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; @@ -602,7 +602,7 @@ namespace CalamityMod.NPCs.Polterghast if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 30; num623++) @@ -617,8 +617,8 @@ namespace CalamityMod.NPCs.Polterghast npc.GivenName = "Necroplasm"; - npc.damage = (int)((float)npc.defDamage * 1.4f); - npc.defense = (int)((float)npc.defDefense * 0.5f); + npc.damage = (int)(npc.defDamage * 1.4f); + npc.defense = (int)(npc.defDefense * 0.5f); if (speedBoost || npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) { @@ -632,9 +632,9 @@ namespace CalamityMod.NPCs.Polterghast npc.ai[1] = 0f; Vector2 vector93 = new Vector2(vector.X, vector.Y); float num742 = CalamityWorld.bossRushActive ? 7f : 5f; - float num743 = player.position.X + (float)player.width * 0.5f - vector93.X; - float num744 = player.position.Y + (float)player.height * 0.5f - vector93.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num743 = player.position.X + player.width * 0.5f - vector93.X; + float num744 = player.position.Y + player.height * 0.5f - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; @@ -648,7 +648,7 @@ namespace CalamityMod.NPCs.Polterghast float rotation = MathHelper.ToRadians(spread); float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); double startAngle = Math.Atan2(num743, num744) - rotation / 2; - double deltaAngle = rotation / (float)numProj; + double deltaAngle = rotation / numProj; double offsetAngle; int type = ModContent.ProjectileType(); for (int i = 0; i < numProj; i++) @@ -668,15 +668,15 @@ namespace CalamityMod.NPCs.Polterghast npc.localAI[1] = 0f; float num757 = 8f; - Vector2 vector94 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num758 = player.position.X + (float)player.width * 0.5f - vector94.X; + Vector2 vector94 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num758 = player.position.X + player.width * 0.5f - vector94.X; float num759 = Math.Abs(num758 * 0.2f); - float num760 = player.position.Y + (float)player.height * 0.5f - vector94.Y; + float num760 = player.position.Y + player.height * 0.5f - vector94.Y; if (num760 > 0f) num759 = 0f; num760 -= num759; - float num761 = (float)Math.Sqrt((double)(num758 * num758 + num760 * num760)); + float num761 = (float)Math.Sqrt(num758 * num758 + num760 * num760); num761 = num757 / num761; num758 *= num761; num760 *= num761; @@ -706,6 +706,8 @@ namespace CalamityMod.NPCs.Polterghast DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedPolterghast); DropHelper.DropResidentEvilAmmo(npc, CalamityWorld.downedPolterghast, 6, 3, 2); + npc.Calamity().SetNewShopVariable(new int[] { NPCID.Cyborg }, CalamityWorld.downedPolterghast); + // All other drops are contained in the bag, so they only drop directly on Normal if (!Main.expertMode) { diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 7540faac35..8e609a7ef9 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -168,7 +168,7 @@ namespace CalamityMod.NPCs.Providence bool normalAttackRate = true; // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; // Phases bool ignoreGuardianAmt = lifeRatio < (death ? 0.2f : 0.15f); @@ -327,17 +327,17 @@ namespace CalamityMod.NPCs.Providence // Guardian spawn if (bossLife == 0f && npc.life > 0) - bossLife = (float)npc.lifeMax; + bossLife = npc.lifeMax; if (npc.life > 0) { if (Main.netMode != NetmodeID.MultiplayerClient) { int num660 = (int)(npc.lifeMax * 0.66); - if ((float)(npc.life + num660) < bossLife) + if ((npc.life + num660) < bossLife) { - bossLife = (float)npc.life; - int x = (int)(npc.position.X + (float)Main.rand.Next(npc.width - 32)); - int y = (int)(npc.position.Y + (float)Main.rand.Next(npc.height - 32)); + bossLife = npc.life; + int x = (int)(npc.position.X + Main.rand.Next(npc.width - 32)); + int y = (int)(npc.position.Y + Main.rand.Next(npc.height - 32)); NPC.NewNPC(x - 100, y - 100, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); NPC.NewNPC(x + 100, y - 100, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); NPC.NewNPC(x, y + 100, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); @@ -417,13 +417,13 @@ namespace CalamityMod.NPCs.Providence if (!targetDead) { - npc.velocity.X += (float)flightPath * acceleration; + npc.velocity.X += flightPath * acceleration; if (npc.velocity.X > velocity) npc.velocity.X = velocity; if (npc.velocity.X < -velocity) npc.velocity.X = -velocity; - float num855 = player.position.Y - (npc.position.Y + (float)npc.height); + float num855 = player.position.Y - (npc.position.Y + npc.height); if (num855 < (firingLaser ? 150f : 200f)) // 150 npc.velocity.Y -= 0.2f; if (num855 > (firingLaser ? 200f : 250f)) // 200 @@ -637,7 +637,7 @@ namespace CalamityMod.NPCs.Providence phase = 0; // Reset arrays - npc.ai[0] = (float)phase; + npc.ai[0] = phase; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; @@ -661,15 +661,15 @@ namespace CalamityMod.NPCs.Providence num856 = (int)(num856 * attackRateMult); - if (npc.ai[3] >= (float)num856) - npc.ai[3] = (float)-(float)num856; + if (npc.ai[3] >= num856) + npc.ai[3] = -num856; if (npc.ai[3] == 0f && Main.netMode != NetmodeID.MultiplayerClient) { vector.X += npc.velocity.X * 7f; - float num857 = player.position.X + (float)player.width * 0.5f - vector.X; + float num857 = player.position.X + player.width * 0.5f - vector.X; float num858 = player.Center.Y - vector.Y; - float num859 = (float)Math.Sqrt((double)(num857 * num857 + num858 * num858)); + float num859 = (float)Math.Sqrt(num857 * num857 + num858 * num858); float velocityBoost = death ? 2.5f : 2.5f * (1f - lifeRatio); float num860 = (expertMode ? 10.25f : 9f) + velocityBoost; @@ -712,11 +712,11 @@ namespace CalamityMod.NPCs.Providence num864 = (int)(num864 * attackRateMult); - if (npc.ai[3] >= (float)num864) + if (npc.ai[3] >= num864) { npc.ai[3] = 0f; - Vector2 vector113 = new Vector2(vector.X, npc.position.Y + (float)npc.height - 14f); + Vector2 vector113 = new Vector2(vector.X, npc.position.Y + npc.height - 14f); float num865 = npc.velocity.Y; if (num865 < 0f) @@ -743,13 +743,13 @@ namespace CalamityMod.NPCs.Providence npc.TargetClosest(true); Vector2 vector114 = new Vector2(vector.X, vector.Y + 20f); - float num866 = (float)Main.rand.Next(-1000, 1001); - float num867 = (float)Main.rand.Next(-1000, 1001); - float num868 = (float)Math.Sqrt((double)(num866 * num866 + num867 * num867)); + float num866 = Main.rand.Next(-1000, 1001); + float num867 = Main.rand.Next(-1000, 1001); + float num868 = (float)Math.Sqrt(num866 * num866 + num867 * num867); float num869 = 3f; if (!targetDead) - npc.velocity *= 0.95f; + npc.velocity *= 0.9f; num868 = num869 / num868; num866 *= num868; @@ -763,7 +763,63 @@ namespace CalamityMod.NPCs.Providence num867 *= -1f; } - npc.ai[3] += 1f; + /*if (npc.velocity.Length() <= 2f) + npc.velocity = Vector2.Zero; + if (npc.velocity.Length() > 2f) + return; + + float divisor = (expertMode ? 2f : 3f) + (float)Math.Floor(3f * lifeRatio) + (attackRateMult > 1D ? (float)Math.Ceiling(attackRateMult * 1.6) : 0f); + int totalProjectiles = 36; + int chains = 4; + float interval = totalProjectiles / chains * divisor; + double patternInterval = Math.Floor(npc.ai[3] / interval); + float velocity = 3f; + + if (patternInterval % 2 == 0) + { + if (npc.ai[3] % divisor == 0f) + { + double radians = (patternInterval % 4 == 0 ? MathHelper.TwoPi + MathHelper.Pi / 3 : MathHelper.TwoPi) / chains; + float radialOffset = MathHelper.ToRadians(npc.ai[2]); + Vector2 fireFrom = new Vector2(vector.X, vector.Y + 20f); + + for (int i = 0; i < chains; i++) + { + Vector2 vector2 = new Vector2(0f, -velocity).RotatedBy(radians * i + radialOffset); + + int projectileType = ModContent.ProjectileType(); + if (Main.rand.NextBool(4) && !death) + projectileType = ModContent.ProjectileType(); + + Projectile.NewProjectile(fireFrom, vector2, projectileType, 0, 0f, Main.myPlayer, 0f, 0f); + } + + // Radial offset + npc.ai[2] += 10f; + } + } + else + { + npc.ai[2] = 0f; + + totalProjectiles = 16; + if (npc.ai[3] % (divisor * totalProjectiles) == 0f) + { + double radians = MathHelper.TwoPi / totalProjectiles; + Vector2 fireFrom = new Vector2(vector.X, vector.Y + 20f); + + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 vector2 = new Vector2(0f, -velocity).RotatedBy(radians * i); + + int projectileType = ModContent.ProjectileType(); + if (Main.rand.NextBool(4) && !death) + projectileType = ModContent.ProjectileType(); + + Projectile.NewProjectile(fireFrom, vector2, projectileType, 0, 0f, Main.myPlayer, 0f, 0f); + } + } + }*/ int shootBoost = (int)(4f * (1f - lifeRatio)); @@ -772,10 +828,10 @@ namespace CalamityMod.NPCs.Providence if (attackRateMult > 1D) num870 += (int)Math.Ceiling(attackRateMult * 1.6); - if (npc.ai[3] >= (float)num870) + npc.ai[1] += 1f; + if (npc.ai[1] >= num870) { - npc.ai[3] = 0f; - + npc.ai[1] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) { if (Main.rand.NextBool(4) && !death) @@ -785,7 +841,7 @@ namespace CalamityMod.NPCs.Providence } } - if (npc.ai[1] == 0f) + if (npc.ai[3] == 0f) { for (int x = 0; x < Main.maxProjectiles; x++) { @@ -801,8 +857,8 @@ namespace CalamityMod.NPCs.Providence } // Air is burning text - npc.ai[1] += 1f; - if (npc.ai[1] >= 450f && !text) + npc.ai[3] += 1f; + if (npc.ai[3] >= 450f && !text) { text = true; string key = "Mods.CalamityMod.ProfanedBossText"; @@ -815,7 +871,7 @@ namespace CalamityMod.NPCs.Providence } // Inflict Icarus Folly - if (npc.ai[1] >= 600f) + if (npc.ai[3] >= 600f) { if (Main.netMode != NetmodeID.Server) { @@ -835,7 +891,7 @@ namespace CalamityMod.NPCs.Providence if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } @@ -875,15 +931,15 @@ namespace CalamityMod.NPCs.Providence num856 = (int)(num856 * attackRateMult); - if (npc.ai[3] >= (float)num856) - npc.ai[3] = (float)-(float)num856; + if (npc.ai[3] >= num856) + npc.ai[3] = -num856; if (npc.ai[3] == 0f && Main.netMode != NetmodeID.MultiplayerClient) { vector.X += npc.velocity.X * 7f; - float num857 = player.position.X + (float)player.width * 0.5f - vector.X; + float num857 = player.position.X + player.width * 0.5f - vector.X; float num858 = player.Center.Y - vector.Y; - float num859 = (float)Math.Sqrt((double)(num857 * num857 + num858 * num858)); + float num859 = (float)Math.Sqrt(num857 * num857 + num858 * num858); float shootBoost2 = death ? 2.5f : 2.5f * (1f - lifeRatio); float num860 = (expertMode ? 10.25f : 9f) + shootBoost2; @@ -926,11 +982,11 @@ namespace CalamityMod.NPCs.Providence num864 = (int)(num864 * attackRateMult); - if (npc.ai[3] >= (float)num864) + if (npc.ai[3] >= num864) { npc.ai[3] = 0f; - Vector2 vector113 = new Vector2(vector.X, npc.position.Y + (float)npc.height - 14f); + Vector2 vector113 = new Vector2(vector.X, npc.position.Y + npc.height - 14f); float num865 = npc.velocity.Y; if (num865 < 0f) @@ -957,7 +1013,7 @@ namespace CalamityMod.NPCs.Providence npc.TargetClosest(true); if (!targetDead) - npc.velocity *= 0.95f; + npc.velocity *= 0.9f; if (npc.ai[1] == 0f) { @@ -987,11 +1043,11 @@ namespace CalamityMod.NPCs.Providence { npc.ai[2] = 0f; - Vector2 vector93 = new Vector2(vector.X, vector.Y); + Vector2 vector93 = vector; float num742 = expertMode ? 12f : 10f; - float num743 = player.position.X + (float)player.width * 0.5f - vector93.X; - float num744 = player.position.Y + (float)player.height * 0.5f - vector93.Y; - float num745 = (float)Math.Sqrt((double)(num743 * num743 + num744 * num744)); + float num743 = player.position.X + player.width * 0.5f - vector93.X; + float num744 = player.position.Y + player.height * 0.5f - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); num745 = num742 / num745; num743 *= num745; @@ -1002,7 +1058,7 @@ namespace CalamityMod.NPCs.Providence int seeProjFilesforDmg = 0; int num747 = ModContent.ProjectileType(); Projectile.NewProjectile(vector93.X, vector93.Y, num743, num744, num747, seeProjFilesforDmg, 0f, Main.myPlayer, 0f, 0f); - Projectile.NewProjectile(player.position.X + (float)Main.rand.Next(-1000, 1000), player.position.Y + (float)Main.rand.Next(-100, 100), 0f, 0f, ModContent.ProjectileType(), seeProjFilesforDmg, 0f, Main.myPlayer, (float)Main.rand.Next(2), 0f); + Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1000), player.position.Y + Main.rand.Next(-100, 100), 0f, 0f, ModContent.ProjectileType(), seeProjFilesforDmg, 0f, Main.myPlayer, (float)Main.rand.Next(2), 0f); } } @@ -1020,7 +1076,7 @@ namespace CalamityMod.NPCs.Providence npc.TargetClosest(true); if (!targetDead) - npc.velocity *= 0.95f; + npc.velocity *= 0.9f; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -1042,7 +1098,7 @@ namespace CalamityMod.NPCs.Providence Vector2 value19 = new Vector2(27f, 59f); - float rotation = 450f + (float)(guardianAmt * 18); + float rotation = 450f + (guardianAmt * 18); npc.ai[2] += 1f; if (npc.ai[2] < 120f) @@ -1064,9 +1120,9 @@ namespace CalamityMod.NPCs.Providence if (num1221 % 2 == 1) num1223 = 2.8f; - Vector2 vector199 = vector + ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * value19 / 2f; + Vector2 vector199 = vector + ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * value19 / 2f; int num1224 = Dust.NewDust(vector199 - Vector2.One * 8f, 16, 16, num1222, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, default, 1f); - Main.dust[num1224].velocity = Vector2.Normalize(vector - vector199) * 3.5f * (10f - (float)num1220 * 2f) / 10f; + Main.dust[num1224].velocity = Vector2.Normalize(vector - vector199) * 3.5f * (10f - num1220 * 2f) / 10f; Main.dust[num1224].noGravity = true; Main.dust[num1224].scale = num1223; } @@ -1093,13 +1149,13 @@ namespace CalamityMod.NPCs.Providence if (vector200.X < 0f) num1225 = 1f; - vector200 = vector200.RotatedBy((double)(-(double)num1225 * 6.28318548f / 6f), default); - Projectile.NewProjectile(vector.X, vector.Y - 32f, vector200.X, vector200.Y, ModContent.ProjectileType(), 100, 0f, Main.myPlayer, num1225 * 6.28318548f / rotation, (float)npc.whoAmI); + vector200 = vector200.RotatedBy(-(double)num1225 * MathHelper.TwoPi / 6f, default); + Projectile.NewProjectile(vector.X, vector.Y - 32f, vector200.X, vector200.Y, ModContent.ProjectileType(), 100, 0f, Main.myPlayer, num1225 * MathHelper.TwoPi / rotation, npc.whoAmI); if (revenge) - Projectile.NewProjectile(vector.X, vector.Y - 32f, -vector200.X, -vector200.Y, ModContent.ProjectileType(), 100, 0f, Main.myPlayer, -num1225 * 6.28318548f / rotation, (float)npc.whoAmI); + Projectile.NewProjectile(vector.X, vector.Y - 32f, -vector200.X, -vector200.Y, ModContent.ProjectileType(), 100, 0f, Main.myPlayer, -num1225 * MathHelper.TwoPi / rotation, npc.whoAmI); - npc.ai[3] = (vector200.ToRotation() + 9.424778f) * num1225; + npc.ai[3] = (vector200.ToRotation() + MathHelper.TwoPi + MathHelper.Pi) * num1225; npc.netUpdate = true; } } @@ -1108,12 +1164,12 @@ namespace CalamityMod.NPCs.Providence if (npc.localAI[1] > 1f) npc.localAI[1] = 1f; - float num1226 = (float)(npc.ai[3] >= 0f).ToDirectionInt(); + float num1226 = (npc.ai[3] >= 0f).ToDirectionInt(); float num1227 = npc.ai[3]; if (num1227 < 0f) num1227 *= -1f; - num1227 += -9.424778f; - num1227 += num1226 * 6.28318548f / rotation; + num1227 += -(MathHelper.TwoPi + MathHelper.Pi); + num1227 += num1226 * MathHelper.TwoPi / rotation; npc.localAI[0] = num1227; } diff --git a/NPCs/Ravager/FlamePillar.cs b/NPCs/Ravager/FlamePillar.cs index 16e58f39f9..6e3706c2fa 100644 --- a/NPCs/Ravager/FlamePillar.cs +++ b/NPCs/Ravager/FlamePillar.cs @@ -55,37 +55,34 @@ namespace CalamityMod.NPCs.Ravager npc.netUpdate = true; return; } - if (npc.timeLeft < 1800) - { - npc.timeLeft = 1800; - } - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0f, 0.5f, 0.5f); + if (npc.timeLeft < 1800) + npc.timeLeft = 1800; + + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0f, 0.5f, 0.5f); if (npc.alpha > 0) { npc.alpha -= 3; if (npc.alpha < 0) - { - if (CalamityWorld.downedProvidence && !CalamityWorld.bossRushActive) - { - npc.damage = 400; - } - else - { - npc.damage = Main.expertMode ? 180 : 100; - } - npc.alpha = 0; - } + npc.alpha = 0; } + if (npc.ai[0] == 0f) { npc.noTileCollide = false; + npc.ai[1] += 1f; + if (npc.ai[1] >= 85f) + { + if (CalamityWorld.downedProvidence && !CalamityWorld.bossRushActive) + npc.damage = 400; + else + npc.damage = Main.expertMode ? 180 : 100; + } + if (npc.ai[1] >= 180f) - { npc.ai[0] = 1f; - } } else if (npc.ai[0] == 1f) { @@ -126,9 +123,9 @@ namespace CalamityMod.NPCs.Ravager 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 / 2)); + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); @@ -150,12 +147,12 @@ namespace CalamityMod.NPCs.Ravager { if (npc.life <= 0) { - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); npc.width = 50; npc.height = 180; - npc.position.X = npc.position.X - (float)(npc.width / 2); - npc.position.Y = npc.position.Y - (float)(npc.height / 2); + npc.position.X = npc.position.X - (npc.width / 2); + npc.position.Y = npc.position.Y - (npc.height / 2); for (int num621 = 0; num621 < 30; num621++) { int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 135, 0f, 0f, 100, default, 2f); @@ -163,7 +160,7 @@ namespace CalamityMod.NPCs.Ravager if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 30; num623++) diff --git a/NPCs/Signus/Signus.cs b/NPCs/Signus/Signus.cs index c162a24ea9..7df77f7d7a 100644 --- a/NPCs/Signus/Signus.cs +++ b/NPCs/Signus/Signus.cs @@ -769,13 +769,7 @@ namespace CalamityMod.NPCs.Signus // Weapons DropHelper.DropItemChance(npc, ModContent.ItemType(), Main.expertMode ? 3 : 4); - float f = Main.rand.NextFloat(); - bool replaceWithRare = f <= DropHelper.RareVariantDropRateFloat; // 1/40 chance overall of getting Guidelight of Oblivion - if (f <= (Main.expertMode ? 0.3333f : 0.25f)) // 1/3 (1/4 in normal) chance of getting Cosmilamp OR Guidelight of Oblivion replacing it - { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !replaceWithRare); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), replaceWithRare); - } + DropHelper.DropItemRIV(npc, ModContent.ItemType(), ModContent.ItemType(), Main.expertMode ? 0.3333f : 0.25f, DropHelper.RareVariantDropRateFloat); //Equipment DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, 4, 1, 1); diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 8daeaf3609..e34674ac77 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -97,7 +97,7 @@ namespace CalamityMod.NPCs.SlimeGod bool death = CalamityWorld.death || CalamityWorld.bossRushActive; // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; npc.TargetClosest(true); Player player = Main.player[npc.target]; @@ -170,7 +170,7 @@ namespace CalamityMod.NPCs.SlimeGod if (npc.velocity.Y > 16f) npc.velocity.Y = 16f; - if ((double)npc.position.Y > Main.worldSurface * 16.0) + if (npc.position.Y > Main.worldSurface * 16.0) { for (int x = 0; x < 200; x++) { @@ -208,14 +208,14 @@ namespace CalamityMod.NPCs.SlimeGod { if (npc.Calamity().newAI[2] == 0f && npc.life > 0) { - npc.Calamity().newAI[2] = (float)npc.lifeMax; + npc.Calamity().newAI[2] = npc.lifeMax; } if (npc.life > 0) { - int num660 = (int)((double)npc.lifeMax * 0.05); - if ((float)(npc.life + num660) < npc.Calamity().newAI[2]) + int num660 = (int)(npc.lifeMax * 0.05); + if ((npc.life + num660) < npc.Calamity().newAI[2]) { - npc.Calamity().newAI[2] = (float)npc.life; + npc.Calamity().newAI[2] = npc.life; npc.Calamity().newAI[3] = 1f; } } @@ -281,8 +281,8 @@ namespace CalamityMod.NPCs.SlimeGod int playerPosX = (int)player.Center.X / 16 + teleportX; int playerPosY = (int)player.Center.Y / 16 - teleportY; - npc.ai[2] = (float)playerPosX; - npc.ai[3] = (float)playerPosY; + npc.ai[2] = playerPosX; + npc.ai[3] = playerPosY; npc.localAI[1] = 1f; npc.netUpdate = true; } @@ -295,7 +295,7 @@ namespace CalamityMod.NPCs.SlimeGod // Teleport to location if (npc.alpha == 255) { - Vector2 position = new Vector2(npc.ai[2] * 16f - (float)(npc.width / 2), npc.ai[3] * 16f - (float)(npc.height / 2)); + Vector2 position = new Vector2(npc.ai[2] * 16f - (npc.width / 2), npc.ai[3] * 16f - (npc.height / 2)); npc.position = position; } @@ -304,7 +304,7 @@ namespace CalamityMod.NPCs.SlimeGod if (npc.alpha < 55) { npc.alpha = 55; - npc.localAI[0] = (vectorCenter.X - player.Center.X < 0 ? 1f : -1f); + npc.localAI[0] = vectorCenter.X - player.Center.X < 0 ? 1f : -1f; npc.localAI[1] = 2f; } npc.netUpdate = true; @@ -315,7 +315,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.damage = 0; // Rotation - npc.rotation += (float)npc.direction * 0.3f; + npc.rotation += npc.direction * 0.3f; // Velocity boost if (npc.localAI[1] == 2f) @@ -325,11 +325,11 @@ namespace CalamityMod.NPCs.SlimeGod } // Spin velocity - float velocity = (float)(Math.PI * 2D) / (360f - (npc.ai[1] - ai1)); - npc.velocity = npc.velocity.RotatedBy((double)(-(double)velocity * npc.localAI[0])); + float velocity = MathHelper.TwoPi / (180f - (npc.ai[1] - ai1)); + npc.velocity = npc.velocity.RotatedBy(-(double)velocity * npc.localAI[0]); // Reset and charge at target - if (npc.ai[1] >= ai1 + 200f) + if (npc.ai[1] >= ai1 + 100f) { npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -343,18 +343,18 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { - if (npc.ai[1] % 20f == 0f && Vector2.Distance(player.Center, vectorCenter) > 160f) + if (npc.ai[1] % 10f == 0f && Vector2.Distance(player.Center, vectorCenter) > 160f) { if (expertMode && Main.rand.NextBool(2)) { float num179 = revenge ? 2f : 3f; if (CalamityWorld.bossRushActive) num179 = 12f; - Vector2 value9 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num180 = player.position.X + (float)player.width * 0.5f - value9.X; + Vector2 value9 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num180 = player.position.X + player.width * 0.5f - value9.X; float num181 = Math.Abs(num180) * 0.1f; - float num182 = player.position.Y + (float)player.height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); + float num182 = player.position.Y + player.height * 0.5f - value9.Y - num181; + float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); npc.netUpdate = true; num183 = num179 / num183; num180 *= num183; @@ -372,9 +372,9 @@ namespace CalamityMod.NPCs.SlimeGod } value9.X += num180; value9.Y += num182; - num180 = player.position.X + (float)player.width * 0.5f - value9.X; - num182 = player.position.Y + (float)player.height * 0.5f - value9.Y; - num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); + num180 = player.position.X + player.width * 0.5f - value9.X; + num182 = player.position.Y + player.height * 0.5f - value9.Y; + num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); num183 = num179 / num183; num180 *= num183; num182 *= num183; @@ -385,11 +385,11 @@ namespace CalamityMod.NPCs.SlimeGod float num179 = revenge ? 6f : 5f; if (CalamityWorld.bossRushActive) num179 = 12f; - Vector2 value9 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num180 = player.position.X + (float)player.width * 0.5f - value9.X; + Vector2 value9 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num180 = player.position.X + player.width * 0.5f - value9.X; float num181 = Math.Abs(num180) * 0.1f; - float num182 = player.position.Y + (float)player.height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); + float num182 = player.position.Y + player.height * 0.5f - value9.Y - num181; + float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); npc.netUpdate = true; num183 = num179 / num183; num180 *= num183; @@ -407,9 +407,9 @@ namespace CalamityMod.NPCs.SlimeGod } value9.X += num180; value9.Y += num182; - num180 = player.position.X + (float)player.width * 0.5f - value9.X; - num182 = player.position.Y + (float)player.height * 0.5f - value9.Y; - num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); + num180 = player.position.X + player.width * 0.5f - value9.X; + num182 = player.position.Y + player.height * 0.5f - value9.Y; + num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); num183 = num179 / num183; num180 *= num183; num182 *= num183; @@ -432,11 +432,11 @@ namespace CalamityMod.NPCs.SlimeGod float num179 = revenge ? 2f : 3f; if (CalamityWorld.bossRushActive) num179 = 12f; - Vector2 value9 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num180 = player.position.X + (float)player.width * 0.5f - value9.X; + Vector2 value9 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num180 = player.position.X + player.width * 0.5f - value9.X; float num181 = Math.Abs(num180) * 0.1f; - float num182 = player.position.Y + (float)player.height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); + float num182 = player.position.Y + player.height * 0.5f - value9.Y - num181; + float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); npc.netUpdate = true; num183 = num179 / num183; num180 *= num183; @@ -454,9 +454,9 @@ namespace CalamityMod.NPCs.SlimeGod } value9.X += num180; value9.Y += num182; - num180 = player.position.X + (float)player.width * 0.5f - value9.X; - num182 = player.position.Y + (float)player.height * 0.5f - value9.Y; - num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); + num180 = player.position.X + player.width * 0.5f - value9.X; + num182 = player.position.Y + player.height * 0.5f - value9.Y; + num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); num183 = num179 / num183; num180 *= num183; num182 *= num183; @@ -467,11 +467,11 @@ namespace CalamityMod.NPCs.SlimeGod float num179 = revenge ? 6f : 5f; if (CalamityWorld.bossRushActive) num179 = 12f; - Vector2 value9 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num180 = player.position.X + (float)player.width * 0.5f - value9.X; + Vector2 value9 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num180 = player.position.X + player.width * 0.5f - value9.X; float num181 = Math.Abs(num180) * 0.1f; - float num182 = player.position.Y + (float)player.height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); + float num182 = player.position.Y + player.height * 0.5f - value9.Y - num181; + float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); npc.netUpdate = true; num183 = num179 / num183; num180 *= num183; @@ -491,12 +491,12 @@ namespace CalamityMod.NPCs.SlimeGod value9.Y += num182; for (int num186 = 0; num186 < 2; num186++) { - num180 = player.position.X + (float)player.width * 0.5f - value9.X; - num182 = player.position.Y + (float)player.height * 0.5f - value9.Y; - num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); + num180 = player.position.X + player.width * 0.5f - value9.X; + num182 = player.position.Y + player.height * 0.5f - value9.Y; + num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); num183 = num179 / num183; - num180 += (float)Main.rand.Next(-30, 31); - num182 += (float)Main.rand.Next(-30, 31); + num180 += Main.rand.Next(-30, 31); + num182 += Main.rand.Next(-30, 31); num180 *= num183; num182 *= num183; Projectile.NewProjectile(value9.X, value9.Y, num180, num182, num185, num184, 0f, Main.myPlayer, 0f, 0f); @@ -524,11 +524,15 @@ namespace CalamityMod.NPCs.SlimeGod { num1372 += 8f; } + if (hyperMode) + { + num1372 *= 1.25f; + } - Vector2 vector167 = new Vector2(vectorCenter.X + (float)(npc.direction * 20), vectorCenter.Y + 6f); - float num1373 = player.position.X + (float)player.width * 0.5f - vector167.X; + Vector2 vector167 = new Vector2(vectorCenter.X + (npc.direction * 20), vectorCenter.Y + 6f); + float num1373 = player.position.X + player.width * 0.5f - vector167.X; float num1374 = player.Center.Y - vector167.Y; - float num1375 = (float)Math.Sqrt((double)(num1373 * num1373 + num1374 * num1374)); + float num1375 = (float)Math.Sqrt(num1373 * num1373 + num1374 * num1374); float num1376 = num1372 / num1375; num1373 *= num1376; num1374 *= num1376; @@ -548,7 +552,7 @@ namespace CalamityMod.NPCs.SlimeGod { npc.direction = 1; } - npc.rotation += (float)npc.direction * 0.3f; + npc.rotation += npc.direction * 0.3f; return; } diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 0087861c9d..1229c1a4e8 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -99,7 +99,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.value = Item.buyPrice(10, 0, 0, 0); npc.LifeMaxNERB(5000000, 5500000, 2100000); double HPBoost = (double)CalamityMod.CalamityConfig.BossHealthPercentageBoost * 0.01; - npc.lifeMax += (int)((double)npc.lifeMax * HPBoost); + npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; @@ -232,6 +232,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; bool death = CalamityWorld.death || CalamityWorld.bossRushActive; + bool enraged = npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive); Vector2 vectorCenter = npc.Center; // Get a target @@ -449,7 +450,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.netMode != NetmodeID.MultiplayerClient) { bulletHellCounter += 1; - if (bulletHellCounter > ((npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) ? 4 : 6)) + if (bulletHellCounter > (enraged ? 4 : 6)) { bulletHellCounter = 0; int damage = expertMode ? 200 : 250; //800 500 @@ -548,7 +549,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } bulletHellCounter += 1; - if (bulletHellCounter > ((npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) ? 7 : 9)) + if (bulletHellCounter > (enraged ? 7 : 9)) { bulletHellCounter = 0; if (bulletHellCounter2 < 1200) //blasts from below @@ -609,10 +610,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas } if (bulletHellCounter2 % 240 == 0) //fireblasts from above { - Projectile.NewProjectile(player.position.X + (float)Main.rand.Next(-1000, 1000), player.position.Y - 1000f, 0f, 10f * uDieLul, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 1f, 0f); + Projectile.NewProjectile(player.position.X + (float)Main.rand.Next(-1000, 1000), player.position.Y - 1000f, 0f, 10f * uDieLul, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); } bulletHellCounter += 1; - if (bulletHellCounter > ((npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) ? 9 : 11)) + if (bulletHellCounter > (enraged ? 9 : 11)) { bulletHellCounter = 0; if (bulletHellCounter2 < 2100) //blasts from above @@ -678,7 +679,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } if (bulletHellCounter2 % 240 == 0) //fireblasts from above { - Projectile.NewProjectile(player.position.X + (float)Main.rand.Next(-1000, 1000), player.position.Y - 1000f, 0f, 10f * uDieLul, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 1f, 0f); + Projectile.NewProjectile(player.position.X + (float)Main.rand.Next(-1000, 1000), player.position.Y - 1000f, 0f, 10f * uDieLul, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); } if (bulletHellCounter2 % 225 == 0) //giant homing fireballs { @@ -686,7 +687,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas passedVar += 1f; } bulletHellCounter += 1; - if (bulletHellCounter > ((npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) ? 10 : 12)) + if (bulletHellCounter > (enraged ? 10 : 12)) { bulletHellCounter = 0; if (bulletHellCounter2 < 3000) //blasts from below @@ -752,14 +753,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas } if (bulletHellCounter2 % 360 == 0) //fireblasts from above { - Projectile.NewProjectile(player.position.X + (float)Main.rand.Next(-1000, 1000), player.position.Y - 1000f, 0f, 10f * uDieLul, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 1f, 0f); + Projectile.NewProjectile(player.position.X + (float)Main.rand.Next(-1000, 1000), player.position.Y - 1000f, 0f, 10f * uDieLul, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); } if (bulletHellCounter2 % 30 == 0) //projectiles that move in wave pattern { Projectile.NewProjectile(player.position.X + 1000f, player.position.Y + (float)Main.rand.Next(-500, 500), -5f * uDieLul, 0f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); } bulletHellCounter += 1; - if (bulletHellCounter > ((npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) ? 12 : 14)) + if (bulletHellCounter > (enraged ? 12 : 14)) { bulletHellCounter = 0; if (bulletHellCounter2 < 3900) //blasts from above @@ -2248,7 +2249,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { - return !CalamityUtils.AntiButcher(npc, ref damage, 0.1f); + return !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); } public override bool CheckActive() diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 5462edc67a..83849aeff2 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -216,6 +216,9 @@ namespace CalamityMod.NPCs.Yharon return; } + if (phaseOneLoot) + npc.Calamity().AITimer = 0; + // Don't drop phase 1 loot phaseOneLoot = false; @@ -225,6 +228,12 @@ namespace CalamityMod.NPCs.Yharon return; } + if (CalamityWorld.buffedEclipse) + { + if (npc.Calamity().AITimer < 3600) + npc.Calamity().AITimer = 3600; + } + // Phase bools 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); @@ -413,7 +422,7 @@ namespace CalamityMod.NPCs.Yharon } // Rotation - float npcRotation = (float)Math.Atan2((double)(player.Center.Y - vectorCenter.Y), (double)(player.Center.X - vectorCenter.X)); + float npcRotation = (float)Math.Atan2(player.Center.Y - vectorCenter.Y, player.Center.X - vectorCenter.X); if (npc.spriteDirection == 1) npcRotation += pie; if (npcRotation < 0f) @@ -522,13 +531,13 @@ namespace CalamityMod.NPCs.Yharon } // Dust - if (npc.ai[2] == (float)(num1457 - 30)) + if (npc.ai[2] == num1457 - 30) { int num1468 = 72; 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)) * MathHelper.TwoPi / (float)num1468), default) + npc.Center; + Vector2 vector169 = Vector2.Normalize(npc.velocity) * new Vector2(npc.width / 2f, npc.height) * 0.75f * 0.5f; + vector169 = vector169.RotatedBy((num1469 - (num1468 / 2 - 1)) * MathHelper.TwoPi / 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; @@ -540,7 +549,7 @@ namespace CalamityMod.NPCs.Yharon } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num1464) + if (npc.ai[2] >= num1464) { npc.ai[0] = 0f; npc.ai[1] = 0f; @@ -1613,7 +1622,7 @@ namespace CalamityMod.NPCs.Yharon 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)); + npc.ai[1] = 360 * Math.Sign((vectorCenter - player.Center).X); } Vector2 value7 = player.Center + new Vector2(npc.ai[1], (float)teleportLocation) - vectorCenter; //teleport distance @@ -1639,7 +1648,7 @@ namespace CalamityMod.NPCs.Yharon } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)aiChangeRate) + if (npc.ai[2] >= aiChangeRate) { int aiState = 0; switch ((int)npc.ai[3]) @@ -1680,7 +1689,7 @@ namespace CalamityMod.NPCs.Yharon 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); + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); if (num32 != 0) { @@ -1719,9 +1728,9 @@ namespace CalamityMod.NPCs.Yharon 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)) * (double)pie / (double)(float)num34, default) + vectorCenter; - Vector2 value8 = ((float)(Main.rand.NextDouble() * (double)pie) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); + Vector2 vector11 = Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f; + vector11 = vector11.RotatedBy((m - (num34 / 2 - 1)) * pie / num34, default) + vectorCenter; + Vector2 value8 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * 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; @@ -1730,7 +1739,7 @@ namespace CalamityMod.NPCs.Yharon } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)chargeTime) + if (npc.ai[2] >= chargeTime) { npc.ai[0] = 21f; npc.ai[1] = 0f; @@ -1753,13 +1762,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)(num1460 / 2)) + if (npc.ai[2] == 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 (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == num1460 / 2) { if (npc.ai[1] == 0f) - npc.ai[1] = (float)(300 * Math.Sign((vectorCenter - player.Center).X)); + npc.ai[1] = 300 * Math.Sign((vectorCenter - player.Center).X); Vector2 center = player.Center + new Vector2(-npc.ai[1], teleportLocation); //teleport distance vectorCenter = npc.Center = center; @@ -1784,7 +1793,7 @@ namespace CalamityMod.NPCs.Yharon } npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num1460) + if (npc.ai[2] >= num1460) { npc.ai[0] = 21f; npc.ai[1] = 0f; @@ -1792,7 +1801,7 @@ namespace CalamityMod.NPCs.Yharon 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)); + Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.target + 1); if (npc.ai[3] >= 20f) //14 npc.ai[3] = 0f; @@ -1808,11 +1817,11 @@ namespace CalamityMod.NPCs.Yharon npc.velocity *= 0.98f; npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - if (npc.ai[2] == (float)(num1459 - 60)) + if (npc.ai[2] == 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) + if (npc.ai[2] >= num1459) { startSecondAI = true; npc.ai[0] = 0f; @@ -3063,7 +3072,7 @@ namespace CalamityMod.NPCs.Yharon #region StrikeNPC public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { - if (CalamityUtils.AntiButcher(npc, ref damage, 0.1f)) + if (CalamityUtils.AntiButcher(npc, ref damage, 0.5f)) return false; // Safeguard to prevent damage which would allow skipping phase 2. diff --git a/Projectiles/Boss/BigFlare.cs b/Projectiles/Boss/BigFlare.cs index 7c85e55b01..57ba185e96 100644 --- a/Projectiles/Boss/BigFlare.cs +++ b/Projectiles/Boss/BigFlare.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Boss projectile.hostile = true; projectile.alpha = 255; projectile.penetrate = -1; - projectile.timeLeft = 600; + projectile.timeLeft = 1200; projectile.scale = 1.5f; } diff --git a/Projectiles/Boss/BigFlare2.cs b/Projectiles/Boss/BigFlare2.cs index 22f9777ffa..e00325d4f9 100644 --- a/Projectiles/Boss/BigFlare2.cs +++ b/Projectiles/Boss/BigFlare2.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Boss projectile.hostile = true; projectile.alpha = 255; projectile.penetrate = -1; - projectile.timeLeft = 600; + projectile.timeLeft = 1200; projectile.scale = 1.5f; } diff --git a/Projectiles/Boss/BirbAuraFlare.cs b/Projectiles/Boss/BirbAuraFlare.cs index bcd79cbe65..95046b04b2 100644 --- a/Projectiles/Boss/BirbAuraFlare.cs +++ b/Projectiles/Boss/BirbAuraFlare.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Boss projectile.hostile = true; projectile.ignoreWater = true; projectile.penetrate = -1; - projectile.timeLeft = 600; + projectile.timeLeft = 1200; } public override void SendExtraAI(BinaryWriter writer) diff --git a/Projectiles/Boss/BrimstoneFireblast.cs b/Projectiles/Boss/BrimstoneFireblast.cs index 67e19569ed..245f83dfb9 100644 --- a/Projectiles/Boss/BrimstoneFireblast.cs +++ b/Projectiles/Boss/BrimstoneFireblast.cs @@ -21,7 +21,6 @@ namespace CalamityMod.Projectiles.Boss projectile.height = 50; projectile.hostile = true; projectile.ignoreWater = true; - projectile.tileCollide = false; projectile.penetrate = 1; projectile.alpha = 120; cooldownSlot = 1; @@ -29,10 +28,6 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - if (projectile.ai[0] == 1f) - { - projectile.tileCollide = true; - } projectile.frameCounter++; if (projectile.frameCounter > 4) { @@ -48,7 +43,7 @@ namespace CalamityMod.Projectiles.Boss { projectile.Kill(); } - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.9f / 255f, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0f / 255f); + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.9f / 255f, 0f, 0f); projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; if (projectile.ai[1] == 0f) { diff --git a/Projectiles/Boss/BrimstoneHellfireball.cs b/Projectiles/Boss/BrimstoneHellfireball.cs index a20804c4b0..300a6ab167 100644 --- a/Projectiles/Boss/BrimstoneHellfireball.cs +++ b/Projectiles/Boss/BrimstoneHellfireball.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Boss projectile.frame++; projectile.frameCounter = 0; } - if (projectile.frame > 5) + if (projectile.frame >= 6) { projectile.frame = 0; } diff --git a/Projectiles/Boss/BrimstoneMonster.cs b/Projectiles/Boss/BrimstoneMonster.cs index b157c40f23..690c378bff 100644 --- a/Projectiles/Boss/BrimstoneMonster.cs +++ b/Projectiles/Boss/BrimstoneMonster.cs @@ -134,24 +134,24 @@ namespace CalamityMod.Projectiles.Boss } // Fly away from other brimstone monsters - float num1247 = 0.5f; - for (int num1248 = 0; num1248 < Main.maxProjectiles; num1248++) + float velocity = 0.1f; + for (int i = 0; i < Main.maxProjectiles; i++) { - if (Main.projectile[num1248].active) + if (Main.projectile[i].active) { - if (num1248 != projectile.whoAmI && Main.projectile[num1248].type == projectile.type) + if (i != projectile.whoAmI && Main.projectile[i].type == projectile.type) { - if (Vector2.Distance(projectile.Center, Main.projectile[num1248].Center) < 320f) + if (Vector2.Distance(projectile.Center, Main.projectile[i].Center) < 320f) { - if (projectile.position.X < Main.projectile[num1248].position.X) - projectile.velocity.X -= num1247; + if (projectile.position.X < Main.projectile[i].position.X) + projectile.velocity.X -= velocity; else - projectile.velocity.X += num1247; + projectile.velocity.X += velocity; - if (projectile.position.Y < Main.projectile[num1248].position.Y) - projectile.velocity.Y -= num1247; + if (projectile.position.Y < Main.projectile[i].position.Y) + projectile.velocity.Y -= velocity; else - projectile.velocity.Y += num1247; + projectile.velocity.Y += velocity; } } } diff --git a/Projectiles/Boss/BrimstoneRay.cs b/Projectiles/Boss/BrimstoneRay.cs index 58a6f26d05..9b9962edb0 100644 --- a/Projectiles/Boss/BrimstoneRay.cs +++ b/Projectiles/Boss/BrimstoneRay.cs @@ -53,6 +53,8 @@ namespace CalamityMod.Projectiles.Boss Vector2 fireFrom = new Vector2(Main.npc[(int)projectile.ai[1]].Center.X + (Main.npc[(int)projectile.ai[1]].spriteDirection > 0 ? 34f : -34f), Main.npc[(int)projectile.ai[1]].Center.Y - 74f); projectile.position = fireFrom - new Vector2((float)projectile.width, (float)projectile.height) / 2f; } + else + projectile.Kill(); float num801 = 1f; projectile.localAI[0] += 1f; diff --git a/Projectiles/Boss/BrimstoneTargetRay.cs b/Projectiles/Boss/BrimstoneTargetRay.cs index 8d1e954070..22ba609b66 100644 --- a/Projectiles/Boss/BrimstoneTargetRay.cs +++ b/Projectiles/Boss/BrimstoneTargetRay.cs @@ -54,6 +54,8 @@ namespace CalamityMod.Projectiles.Boss Vector2 fireFrom = new Vector2(Main.npc[(int)projectile.ai[1]].Center.X + (Main.npc[(int)projectile.ai[1]].spriteDirection > 0 ? 34f : -34f), Main.npc[(int)projectile.ai[1]].Center.Y - 74f); projectile.position = fireFrom - new Vector2((float)projectile.width, (float)projectile.height) / 2f; } + else + projectile.Kill(); Vector2 laserVelocity = new Vector2(Main.npc[(int)projectile.ai[1]].Calamity().newAI[1], Main.npc[(int)projectile.ai[1]].Calamity().newAI[2]); float rotationVelocity = projectile.ai[0] == 0f ? laserVelocity.ToRotation() : projectile.velocity.ToRotation(); diff --git a/Projectiles/Boss/DarkOrb.cs b/Projectiles/Boss/DarkOrb.cs index 49a7a2cc33..d8d9d314dc 100644 --- a/Projectiles/Boss/DarkOrb.cs +++ b/Projectiles/Boss/DarkOrb.cs @@ -13,9 +13,8 @@ namespace CalamityMod.Projectiles.Boss { private bool start = true; private Vector2 center = Vector2.Zero; - private double distance = 0D; - private double distance2 = 0D; private Vector2 velocity = Vector2.Zero; + private double[] distances = new double[4]; public override void SetStaticDefaults() { @@ -39,42 +38,51 @@ namespace CalamityMod.Projectiles.Boss public override void SendExtraAI(BinaryWriter writer) { writer.Write(projectile.localAI[0]); + writer.Write(projectile.localAI[1]); writer.Write(start); writer.WriteVector2(center); - writer.Write(distance); - writer.Write(distance2); + writer.Write(distances[0]); + writer.Write(distances[1]); + writer.Write(distances[2]); + writer.Write(distances[3]); writer.WriteVector2(velocity); } public override void ReceiveExtraAI(BinaryReader reader) { projectile.localAI[0] = reader.ReadSingle(); + projectile.localAI[1] = reader.ReadSingle(); start = reader.ReadBoolean(); center = reader.ReadVector2(); - distance = reader.ReadDouble(); - distance2 = reader.ReadDouble(); + distances[0] = reader.ReadDouble(); + distances[1] = reader.ReadDouble(); + distances[2] = reader.ReadDouble(); + distances[3] = reader.ReadDouble(); velocity = reader.ReadVector2(); } public override void AI() { - // Pulse in and out - if (projectile.localAI[1] == 0f) + if (projectile.ai[0] != 8f) { - projectile.scale -= 0.006f; - if (projectile.scale <= 0.9f) + // Pulse in and out + if (projectile.localAI[1] == 0f) { - projectile.scale = 0.9f; - projectile.localAI[1] = 1f; + projectile.scale -= 0.012f; + if (projectile.scale <= 0.8f) + { + projectile.scale = 0.8f; + projectile.localAI[1] = 1f; + } } - } - else - { - projectile.scale += 0.006f; - if (projectile.scale >= 1.1f) + else { - projectile.scale = 1.1f; - projectile.localAI[1] = 0f; + projectile.scale += 0.012f; + if (projectile.scale >= 1.2f) + { + projectile.scale = 1.2f; + projectile.localAI[1] = 0f; + } } } @@ -84,14 +92,14 @@ namespace CalamityMod.Projectiles.Boss case -1: break; - // Rotate around a point and spread outward + // Rotate around a point, spread outward and move case 0: case 1: if (start) { center = projectile.Center; - velocity = Vector2.Normalize(Main.player[(int)Player.FindClosest(projectile.Center, 1, 1)].Center - projectile.Center) * 2f; + velocity = Vector2.Normalize(Main.player[Player.FindClosest(projectile.Center, 1, 1)].Center - projectile.Center) * 2f; start = false; } @@ -103,17 +111,17 @@ namespace CalamityMod.Projectiles.Boss if (amount < 0f) amount = 0f; - distance += (double)MathHelper.Lerp(1f, 6f, amount); + distances[0] += MathHelper.Lerp(1f, 6f, amount); if (projectile.ai[0] == 0f) { - projectile.position.X = center.X - (int)(Math.Sin(rad) * distance) - projectile.width / 2; - projectile.position.Y = center.Y - (int)(Math.Cos(rad) * distance) - projectile.height / 2; + projectile.position.X = center.X - (int)(Math.Sin(rad) * distances[0]) - projectile.width / 2; + projectile.position.Y = center.Y - (int)(Math.Cos(rad) * distances[0]) - projectile.height / 2; } else { - projectile.position.X = center.X - (int)(Math.Cos(rad) * distance) - projectile.width / 2; - projectile.position.Y = center.Y - (int)(Math.Sin(rad) * distance) - projectile.height / 2; + projectile.position.X = center.X - (int)(Math.Cos(rad) * distances[0]) - projectile.width / 2; + projectile.position.Y = center.Y - (int)(Math.Sin(rad) * distances[0]) - projectile.height / 2; } projectile.ai[1] += 0.25f + amount; @@ -124,9 +132,7 @@ namespace CalamityMod.Projectiles.Boss // Lurch forward case 2: - projectile.ai[1] += 0.05f; - - projectile.velocity *= MathHelper.Lerp(0.95f, 1.05f, (float)Math.Abs(Math.Sin(projectile.ai[1]))); + LurchForward(0.05f, 0.95f, 1.05f); break; @@ -134,41 +140,20 @@ namespace CalamityMod.Projectiles.Boss case 3: case 4: - if (start) - { - velocity = projectile.velocity; - start = false; - } + bool useSin = projectile.ai[0] == 3f; - projectile.ai[1] += 0.1f; - - float wavyVelocity = projectile.ai[0] == 3f ? (float)Math.Sin(projectile.ai[1]) : (float)Math.Cos(projectile.ai[1]); - - projectile.velocity = velocity + new Vector2(wavyVelocity, wavyVelocity) * velocity.Length(); + WavyMotion(0.1f, 0f, useSin); break; // Speed up then slow down on a timer case 5: + case 16: - projectile.ai[1] += 1f; + float fastGateValue = projectile.ai[0] == 5f ? 30f : 60f; + float maxVelocity = projectile.ai[0] == 5f ? 12f : 6f; - float velocityGateValue = 90f; - float velocityGateValue2 = 30f; - if (projectile.ai[1] <= velocityGateValue) - { - if (projectile.velocity.Length() > 3f) - projectile.velocity *= 0.95f; - } - else if (projectile.ai[1] <= velocityGateValue + velocityGateValue2) - { - if (projectile.velocity.Length() < 18f) - projectile.velocity *= 1.1f; - } - else if (projectile.ai[1] == velocityGateValue + velocityGateValue2) - { - projectile.ai[1] = 0f; - } + LurchForwardOnTimer(90f, fastGateValue, 3f, maxVelocity, 0.95f, 1.2f); break; @@ -183,8 +168,8 @@ namespace CalamityMod.Projectiles.Boss { for (int i = 0; i < 4; i++) { - Vector2 vector = new Vector2(0f, -8f).RotatedBy((double)(MathHelper.PiOver2 * (float)i), default); - Projectile.NewProjectile(projectile.Center, vector, projectile.type, projectile.damage, 0f, Main.myPlayer, (float)Main.rand.Next(6), 0f); + Vector2 vector = new Vector2(0f, -8f).RotatedBy(MathHelper.PiOver2 * i); + Projectile.NewProjectile(projectile.Center, vector, projectile.type, projectile.damage, 0f, Main.myPlayer, Main.rand.Next(6), 0f); } } @@ -204,8 +189,8 @@ namespace CalamityMod.Projectiles.Boss { for (int i = 0; i < 8; i++) { - Vector2 vector = new Vector2(0f, -8f).RotatedBy((double)(MathHelper.PiOver4 * (float)i), default); - Projectile.NewProjectile(projectile.Center, vector, projectile.type, projectile.damage, 0f, Main.myPlayer, (float)Main.rand.Next(2), 0f); + Vector2 vector = new Vector2(0f, -8f).RotatedBy(MathHelper.PiOver4 * i); + Projectile.NewProjectile(projectile.Center, vector, projectile.type, projectile.damage, 0f, Main.myPlayer, Main.rand.Next(2), 0f); } } @@ -214,20 +199,47 @@ namespace CalamityMod.Projectiles.Boss break; - // Split into 3 projectiles multiple times + // Split into 3 wavy projectiles multiple times case 8: - projectile.ai[1] += 1f; + bool splitOnce = projectile.timeLeft < 1800; + bool splitTwice = projectile.timeLeft < 900; + bool splitThrice = projectile.timeLeft < 450; - if (projectile.ai[1] >= 120f) + if (splitOnce) + WavyMotion(0.05f, 2f, true); + + projectile.localAI[0] += 1f; + + if (projectile.localAI[0] >= 180f) { if (projectile.owner == Main.myPlayer) { + float randomRotation = MathHelper.ToRadians(Main.rand.NextFloat() * 60f); + float radians = MathHelper.TwoPi / 3f + randomRotation; + int spread = 8; + + if (splitOnce) + { + spread *= (splitTwice ? 3 : 0) + + (splitThrice ? 3 : 0); + } + + Vector2 vector = Main.player[Player.FindClosest(projectile.Center, 1, 1)].Center - projectile.Center; + vector.Normalize(); + vector *= 3f; + for (int i = 0; i < 3; i++) { - Vector2 vector = new Vector2(0f, -8f).RotatedBy((double)(MathHelper.Pi * 0.66666666667f * (float)i), default); - int proj = Projectile.NewProjectile(projectile.Center, vector, projectile.type, projectile.damage, 0f, Main.myPlayer, 8f, 0f); - Main.projectile[proj].timeLeft = projectile.timeLeft / 4; + Vector2 vector2 = splitOnce ? projectile.velocity.RotatedBy(MathHelper.ToRadians(i * spread)) : new Vector2(0f, -3f).RotatedBy(radians * i); + + int proj = Projectile.NewProjectile(projectile.Center, vector + vector2, projectile.type, projectile.damage, 0f, Main.myPlayer, 8f, 0f); + + Main.projectile[proj].timeLeft = projectile.timeLeft / 2; + if (Main.projectile[proj].timeLeft < 150) + Main.projectile[proj].timeLeft = 150; + + Main.projectile[proj].scale = projectile.scale * 0.6f; } } @@ -236,23 +248,17 @@ namespace CalamityMod.Projectiles.Boss break; - // Walls + // idk yet case 9: case 10: - projectile.ai[1] += 1f; + bool useSin2 = projectile.ai[0] == 9f; - if (projectile.ai[1] >= 90f) - { - if (projectile.ai[0] == 9f) - projectile.velocity.X = 0f; - else - projectile.velocity.Y = 0f; - } + OscillationMotion(0.05f, useSin2); break; - // Homing arc + // Homing case 11: projectile.ai[1] += 1f; @@ -262,7 +268,7 @@ namespace CalamityMod.Projectiles.Boss projectile.localAI[0] += 1f; if (projectile.localAI[0] < 180f) { - Vector2 vector = Main.player[(int)Player.FindClosest(projectile.Center, 1, 1)].Center - projectile.Center; + Vector2 vector = Main.player[Player.FindClosest(projectile.Center, 1, 1)].Center - projectile.Center; float scaleFactor = projectile.velocity.Length(); vector.Normalize(); vector *= scaleFactor; @@ -283,7 +289,7 @@ namespace CalamityMod.Projectiles.Boss if (start) { center = projectile.Center; - velocity = Vector2.Normalize(Main.player[(int)Player.FindClosest(projectile.Center, 1, 1)].Center - projectile.Center); + velocity = Vector2.Normalize(Main.player[Player.FindClosest(projectile.Center, 1, 1)].Center - projectile.Center); start = false; } @@ -301,33 +307,236 @@ namespace CalamityMod.Projectiles.Boss amount2 = MathHelper.Clamp(0f, 1f, amount2); - double distanceVariable = (double)MathHelper.Lerp(0f, 6f, amount2); + double distanceVariable = MathHelper.Lerp(0f, 6f, amount2); - distance += (flyOutward ? distanceVariable : -distanceVariable); + distances[0] += flyOutward ? distanceVariable : -distanceVariable; double rad2 = MathHelper.ToRadians(projectile.ai[1]); if (projectile.ai[0] == 12f) { - projectile.position.X = center.X - (int)(Math.Sin(rad2) * distance * 2D) - projectile.width / 2; - projectile.position.Y = center.Y - (int)(Math.Cos(rad2) * distance) - projectile.height / 2; + projectile.position.X = center.X - (int)(Math.Sin(rad2) * distances[0] * 2D) - projectile.width / 2; + projectile.position.Y = center.Y - (int)(Math.Cos(rad2) * distances[0]) - projectile.height / 2; } else { - projectile.position.X = center.X - (int)(Math.Cos(rad2) * distance) - projectile.width / 2; - projectile.position.Y = center.Y - (int)(Math.Sin(rad2) * distance * 2D) - projectile.height / 2; + projectile.position.X = center.X - (int)(Math.Cos(rad2) * distances[0]) - projectile.width / 2; + projectile.position.Y = center.Y - (int)(Math.Sin(rad2) * distances[0] * 2D) - projectile.height / 2; } projectile.ai[1] += 0.25f + amount2; projectile.localAI[0] += 1f; break; + + // Spread out then drift inward after some time and then drift outward + case 14: + case 15: + + float velocityMult = 12f; + + if (start) + { + center = projectile.Center; + velocity = Vector2.Normalize(Main.player[Player.FindClosest(projectile.Center, 1, 1)].Center - projectile.Center) * velocityMult; + start = false; + } + + center += velocity; + + float flyInwardGateValue = 240f; + + float amount3 = 1f - projectile.localAI[0] / flyInwardGateValue; + if (amount3 < 0f) + amount3 = 0f; + + bool changeXPos = projectile.ai[0] == 14f; + + float units = 6f; + + distances[0] += MathHelper.Lerp(1f, units, amount3); + + if (projectile.localAI[0] > flyInwardGateValue) + { + distances[2] = changeXPos ? Math.Abs(center.X - projectile.Center.X) : Math.Abs(center.Y - projectile.Center.Y); + + if (distances[3] == 0D) + distances[3] = distances[2] - units * 10f; + + distances[3] += changeXPos ? velocity.X : velocity.Y; + + distances[1] -= distances[2] < (units * 10f) ? distances[2] * 0.1f : MathHelper.Lerp(units, units + 2f, (float)(distances[2] / distances[3])); + } + else + { + float slowDownGateValue = 30f; + + if (projectile.localAI[0] > flyInwardGateValue - slowDownGateValue) + velocity *= 1f - velocityMult / slowDownGateValue; + + distances[1] = distances[0]; + } + + double distanceX = changeXPos ? distances[1] : distances[0]; + double distanceY = changeXPos ? distances[0] : distances[1]; + + double rad3 = MathHelper.ToRadians(projectile.ai[1]); + + projectile.position.X = center.X - (int)(Math.Sin(rad3) * distanceX) - projectile.width / 2; + projectile.position.Y = center.Y - (int)(Math.Cos(rad3) * distanceY) - projectile.height / 2; + + projectile.localAI[0] += 1f; + + if (projectile.localAI[0] > 600f) + projectile.Kill(); + + break; } } - public override Color? GetAlpha(Color lightColor) + private void WavyMotion(float frequency, float amplitude, bool useSin) + { + if (start) + { + velocity = projectile.velocity; + start = false; + } + + projectile.ai[1] += frequency; + + if (amplitude == 0f) + amplitude = velocity.Length(); + + float wavyVelocity = useSin ? (float)Math.Sin(projectile.ai[1]) : (float)Math.Cos(projectile.ai[1]); + + projectile.velocity = velocity + new Vector2(wavyVelocity, wavyVelocity).RotatedBy(MathHelper.ToRadians(velocity.ToRotation())) * amplitude; + } + + private void LurchForward(float frequncy, float deceleration, float acceleration) + { + projectile.ai[1] += frequncy; + + projectile.velocity *= MathHelper.Lerp(deceleration, acceleration, (float)Math.Abs(Math.Sin(projectile.ai[1]))); + } + + private void LurchForwardOnTimer(float slowGateValue, float fastGateValue, float minVelocity, float maxVelocity, float deceleration, float acceleration) + { + projectile.ai[1] += 1f; + + if (projectile.ai[1] <= slowGateValue) + { + if (projectile.velocity.Length() > minVelocity) + projectile.velocity *= deceleration; + } + else if (projectile.ai[1] < slowGateValue + fastGateValue) + { + if (projectile.velocity.Length() < maxVelocity) + projectile.velocity *= acceleration; + } + else + projectile.ai[1] = 0f; + } + + private void OscillationMotion(float frequncy, bool useSin) + { + projectile.ai[1] += frequncy; + + float oscillation = useSin ? (float)Math.Sin(projectile.ai[1]) : (float)Math.Cos(projectile.ai[1]); + + if (start) + { + velocity = projectile.velocity; + start = false; + } + else if (oscillation == 0f) + { + Player target = Main.player[Player.FindClosest(projectile.Center, 1, 1)]; + Vector2 vector = target.Center + target.velocity * 20f - projectile.Center; + vector.Normalize(); + vector *= velocity.Length(); + projectile.velocity = vector; + } + else + { + float amplitude = velocity.Length(); + + projectile.velocity.Normalize(); + projectile.velocity *= amplitude * oscillation; + } + } + + public override Color? GetAlpha(Color lightColor) { - return new Color(Main.DiscoR, 100, 255, projectile.alpha); + switch ((int)projectile.ai[0]) + { + // No AI + case -1: + + return new Color(0, 100, 255, projectile.alpha); + + // Rotate around a point, spread outward and move + case 0: + case 1: + + return new Color(0, 100, 255, projectile.alpha); + + // Lurch forward + case 2: + + return new Color(255, 200, 0, projectile.alpha); + + // Wavy motion + case 3: + case 4: + + return new Color(0, 255, 200, projectile.alpha); + + // Speed up then slow down on a timer + case 5: + case 16: + + return new Color(0, 255, 100, projectile.alpha); + + // Split into 4 projectiles that can use any of the first 6 AIs + case 6: + + return new Color(200, 0, 255, projectile.alpha); + + // Split into 8 projectiles that can use either of the first 2 AIs + case 7: + + return new Color(255, 0, 150, projectile.alpha); + + // Split into 3 wavy projectiles multiple times + case 8: + + return new Color(200, 0, 0, projectile.alpha); + + // idk yet + case 9: + case 10: + + return new Color(255, 255, 0, projectile.alpha); + + // Homing + case 11: + + return new Color(150, 0, 200, projectile.alpha); + + // Rotate around a moving point and spread outward then inward in an oval pattern + case 12: + case 13: + + return new Color(0, 100, 255, projectile.alpha); + + // Spread out then drift inward after some time and then drift outward + case 14: + case 15: + + return new Color(0, 100, 255, projectile.alpha); + } + + return null; } public override void OnHitPlayer(Player target, int damage, bool crit) diff --git a/Projectiles/Boss/IceRain.cs b/Projectiles/Boss/IceRain.cs index 62a760667e..86e93a70ad 100644 --- a/Projectiles/Boss/IceRain.cs +++ b/Projectiles/Boss/IceRain.cs @@ -1,4 +1,5 @@ using Microsoft.Xna.Framework; +using System; using System.IO; using Terraria; using Terraria.ID; @@ -15,7 +16,6 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.aiStyle = 1; projectile.width = 12; projectile.height = 12; projectile.hostile = true; @@ -34,11 +34,26 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - Lighting.AddLight((int)((projectile.position.X + (float)(projectile.width / 2)) / 16f), (int)((projectile.position.Y + (float)(projectile.height / 2)) / 16f), 0.01f, 0.25f, 0.25f); - if (projectile.ai[0] == 0f) - projectile.velocity.Y = projectile.velocity.Y + 0.2f; + Lighting.AddLight((int)((projectile.position.X + (float)(projectile.width / 2)) / 16f), (int)((projectile.position.Y + (float)(projectile.height / 2)) / 16f), 0f, 0.25f, 0.25f); - if (projectile.localAI[0] == 0f || projectile.localAI[0] == 2f) + if (projectile.ai[0] != 2f) + projectile.aiStyle = 1; + + if (projectile.ai[0] == 0f) + { + projectile.velocity.Y += 0.2f; + } + else if (projectile.ai[0] == 2f) + { + projectile.velocity.Y += 0.1f; + + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; + + if (projectile.velocity.Y > 6f) + projectile.velocity.Y = 6f; + } + + if (projectile.localAI[0] == 0f) { projectile.scale += 0.01f; projectile.alpha -= 50; @@ -48,13 +63,13 @@ namespace CalamityMod.Projectiles.Boss projectile.alpha = 0; } } - else if (projectile.localAI[0] == 1f) + else { projectile.scale -= 0.01f; projectile.alpha += 50; if (projectile.alpha >= 255) { - projectile.localAI[0] = 2f; + projectile.localAI[0] = 0f; projectile.alpha = 255; } } @@ -68,7 +83,6 @@ namespace CalamityMod.Projectiles.Boss public override void Kill(int timeLeft) { Main.PlaySound(2, (int)projectile.Center.X, (int)projectile.Center.Y, 27, 0.25f); - //Main.PlaySound(SoundID.Item27, projectile.position); for (int num373 = 0; num373 < 3; num373++) { int num374 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 76, 0f, 0f, 0, default, 1f); diff --git a/Projectiles/Boss/JewelProjectile.cs b/Projectiles/Boss/JewelProjectile.cs new file mode 100644 index 0000000000..85cf65a83a --- /dev/null +++ b/Projectiles/Boss/JewelProjectile.cs @@ -0,0 +1,59 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class JewelProjectile : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Ruby Bolt"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 2; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } + + public override void SetDefaults() + { + projectile.width = 10; + projectile.height = 10; + projectile.penetrate = 2; + projectile.hostile = true; + } + + public override void AI() + { + projectile.rotation += 0.3f * (float)projectile.direction; + for (int index = 0; index < 2; ++index) + { + int ruby = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 90, projectile.velocity.X, projectile.velocity.Y, 90, new Color(), 1.2f); + Dust dust = Main.dust[ruby]; + dust.noGravity = true; + dust.velocity *= 0.3f; + } + } + + public override Color? GetAlpha(Color drawColor) => new Color(255, 50, 50, 0); + + public override void Kill(int timeLeft) + { + Main.PlaySound(0, (int)projectile.position.X, (int)projectile.position.Y, 1, 1f, 0f); + for (int index1 = 0; index1 < 15; ++index1) + { + int ruby = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 90, projectile.oldVelocity.X, projectile.oldVelocity.Y, 50, new Color(), 1.2f); + Dust dust = Main.dust[ruby]; + dust.noGravity = true; + dust.scale *= 1.25f; + dust.velocity *= 0.5f; + } + } + + 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/JewelProjectile.png b/Projectiles/Boss/JewelProjectile.png new file mode 100644 index 0000000000..c289e663a3 Binary files /dev/null and b/Projectiles/Boss/JewelProjectile.png differ diff --git a/Projectiles/Boss/RedLightning.cs b/Projectiles/Boss/RedLightning.cs index aef7436204..a53b1b96fb 100644 --- a/Projectiles/Boss/RedLightning.cs +++ b/Projectiles/Boss/RedLightning.cs @@ -103,7 +103,7 @@ namespace CalamityMod.Projectiles.Boss Main.dust[num859].scale = 1.2f; num3 = num856; } - if (Main.rand.Next(5) == 0) + if (Main.rand.NextBool(5)) { Vector2 value39 = projectile.velocity.RotatedBy((double)MathHelper.PiOver2, default(Vector2)) * ((float)Main.rand.NextDouble() - 0.5f) * (float)projectile.width; int num860 = Dust.NewDust(projectile.Center + value39 - Vector2.One * 4f, 8, 8, 60, 0f, 0f, 100, default, 1.5f); diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 2179561dc5..733c1d5776 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -2,8 +2,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.Dusts; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs.NormalNPCs; using CalamityMod.Projectiles.Healing; using CalamityMod.Projectiles.Hybrid; using CalamityMod.Projectiles.Magic; @@ -20,6 +19,7 @@ using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles { @@ -61,7 +61,6 @@ namespace CalamityMod.Projectiles // Counters and Timers private int counter = 0; - private int counter2 = 0; public int lineColor = 0; //Note: Although this was intended for fishing line colors, I use this as an AI variable a lot because vanilla only has 4 that sometimes are already in use. ~Ben public bool extorterBoost = false; @@ -140,8 +139,8 @@ namespace CalamityMod.Projectiles { if (projectile.type == ProjectileID.Starfury) { - if (projectile.timeLeft > 60) - projectile.timeLeft = 60; + if (projectile.timeLeft > 45) + projectile.timeLeft = 45; if (projectile.ai[1] == 0f && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) { @@ -170,7 +169,7 @@ namespace CalamityMod.Projectiles projectile.localAI[0] = 1f; } - projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * projectile.direction; if (projectile.ai[1] == 1f) { @@ -222,7 +221,7 @@ namespace CalamityMod.Projectiles if (projectile.timeLeft > 300) projectile.timeLeft = 300; - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 1.57f; if (projectile.velocity.Y > 16f) projectile.velocity.Y = 16f; @@ -237,13 +236,13 @@ namespace CalamityMod.Projectiles { float num623 = 0.209439516f; float num624 = -2f; - float num625 = (float)(Math.Cos((double)(num623 * projectile.ai[0])) - 0.5) * num624; + float num625 = (float)(Math.Cos(num623 * projectile.ai[0]) - 0.5) * num624; projectile.velocity.Y -= num625; projectile.ai[0] += 1f; - num625 = (float)(Math.Cos((double)(num623 * projectile.ai[0])) - 0.5) * num624; + num625 = (float)(Math.Cos(num623 * projectile.ai[0]) - 0.5) * num624; projectile.velocity.Y += num625; @@ -287,19 +286,19 @@ namespace CalamityMod.Projectiles if (projectile.localAI[0] == 0f && Main.myPlayer == projectile.owner) { projectile.localAI[0] = 1f; - projectile.position.X += (float)(projectile.width / 2); - projectile.position.Y += (float)(projectile.height / 2); - projectile.scale = ((float)(num606 + num607) - projectile.ai[1]) * num608 / (float)(num607 + num606); + projectile.position.X += projectile.width / 2; + projectile.position.Y += projectile.height / 2; + projectile.scale = (num606 + num607 - projectile.ai[1]) * num608 / (num607 + num606); projectile.width = (int)(num609 * projectile.scale); projectile.height = (int)(num610 * projectile.scale); - projectile.position.X -= (float)(projectile.width / 2); - projectile.position.Y -= (float)(projectile.height / 2); + projectile.position.X -= projectile.width / 2; + projectile.position.Y -= projectile.height / 2; projectile.netUpdate = true; } if (projectile.ai[1] != -1f) { - projectile.scale = ((float)(num606 + num607) - projectile.ai[1]) * num608 / (float)(num607 + num606); + projectile.scale = (num606 + num607 - projectile.ai[1]) * num608 / (num607 + num606); projectile.width = (int)(num609 * projectile.scale); projectile.height = (int)(num610 * projectile.scale); } @@ -328,10 +327,10 @@ namespace CalamityMod.Projectiles projectile.netUpdate = true; Vector2 center = projectile.Center; - center.Y -= (float)num610 * projectile.scale / 2f; + center.Y -= num610 * projectile.scale / 2f; - float num611 = ((float)(num606 + num607) - projectile.ai[1] + 1f) * num608 / (float)(num607 + num606); - center.Y -= (float)num610 * num611 / 2f; + float num611 = (num606 + num607 - projectile.ai[1] + 1f) * num608 / (num607 + num606); + center.Y -= num610 * num611 / 2f; center.Y += 2f; Projectile.NewProjectile(center.X, center.Y, projectile.velocity.X, projectile.velocity.Y, projectile.type, projectile.damage, projectile.knockBack, projectile.owner, 10f, projectile.ai[1] - 1f); @@ -342,7 +341,7 @@ namespace CalamityMod.Projectiles Main.npc[num614].velocity = projectile.velocity; Main.npc[num614].scale = 1.5f; Main.npc[num614].netUpdate = true; - Main.npc[num614].ai[2] = (float)projectile.width; + Main.npc[num614].ai[2] = projectile.width; Main.npc[num614].ai[3] = -1.5f; } } @@ -350,15 +349,15 @@ namespace CalamityMod.Projectiles if (projectile.ai[0] <= 0f) { float num615 = 0.104719758f; - float num616 = (float)projectile.width / 5f * 2.5f; - float num617 = (float)(Math.Cos((double)(num615 * -(double)projectile.ai[0])) - 0.5) * num616; + float num616 = projectile.width / 5f * 2.5f; + float num617 = (float)(Math.Cos(num615 * -(double)projectile.ai[0]) - 0.5) * num616; - projectile.position.X -= num617 * (float)-(float)projectile.direction; + projectile.position.X -= num617 * -projectile.direction; projectile.ai[0] -= 1f; - num617 = (float)(Math.Cos((double)(num615 * -(double)projectile.ai[0])) - 0.5) * num616; - projectile.position.X += num617 * (float)-(float)projectile.direction; + num617 = (float)(Math.Cos(num615 * -(double)projectile.ai[0]) - 0.5) * num616; + projectile.position.X += num617 * -projectile.direction; } return false; } @@ -379,7 +378,7 @@ namespace CalamityMod.Projectiles { Vector2 value21 = new Vector2(27f, 59f); Vector2 value22 = Utils.Vector2FromElipse(Main.npc[(int)projectile.ai[1]].localAI[0].ToRotationVector2(), value21 * Main.npc[(int)projectile.ai[1]].localAI[1]); - projectile.position = Main.npc[(int)projectile.ai[1]].Center + value22 - new Vector2((float)projectile.width, (float)projectile.height) / 2f; + projectile.position = Main.npc[(int)projectile.ai[1]].Center + value22 - new Vector2(projectile.width, projectile.height) / 2f; } if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) @@ -400,7 +399,7 @@ namespace CalamityMod.Projectiles return false; } - projectile.scale = (float)Math.Sin((double)(projectile.localAI[0] * 3.14159274f / 180f)) * 10f * num801; + projectile.scale = (float)Math.Sin(projectile.localAI[0] * 3.14159274f / 180f) * 10f * num801; if (projectile.scale > num801) { projectile.scale = num801; @@ -412,7 +411,7 @@ namespace CalamityMod.Projectiles projectile.velocity = num804.ToRotationVector2(); float num805 = 3f; - float num806 = (float)projectile.width; + float num806 = projectile.width; Vector2 samplingPoint = projectile.Center; if (vector78.HasValue) @@ -445,7 +444,7 @@ namespace CalamityMod.Projectiles { float num810 = projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * 1.57079637f; float num811 = (float)Main.rand.NextDouble() * 2f + 2f; - Vector2 vector80 = new Vector2((float)Math.Cos((double)num810) * num811, (float)Math.Sin((double)num810) * num811); + Vector2 vector80 = new Vector2((float)Math.Cos(num810) * num811, (float)Math.Sin(num810) * num811); int num812 = Dust.NewDust(vector79, 0, 0, 229, vector80.X, vector80.Y, 0, default, 1f); Main.dust[num812].noGravity = true; Main.dust[num812].scale = 1.7f; @@ -453,14 +452,14 @@ namespace CalamityMod.Projectiles } if (Main.rand.Next(5) == 0) { - Vector2 value29 = projectile.velocity.RotatedBy(1.5707963705062866, default) * ((float)Main.rand.NextDouble() - 0.5f) * (float)projectile.width; + Vector2 value29 = projectile.velocity.RotatedBy(1.5707963705062866, default) * ((float)Main.rand.NextDouble() - 0.5f) * projectile.width; int num813 = Dust.NewDust(vector79 + value29 - Vector2.One * 4f, 8, 8, 31, 0f, 0f, 100, default, 1.5f); Dust dust = Main.dust[num813]; dust.velocity *= 0.5f; Main.dust[num813].velocity.Y = -Math.Abs(Main.dust[num813].velocity.Y); } DelegateMethods.v3_1 = new Vector3(0.3f, 0.65f, 0.7f); - Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], (float)projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); + Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); return false; } @@ -524,7 +523,7 @@ namespace CalamityMod.Projectiles } if (player.MinionDamage() != spawnedPlayerMinionDamageValue) { - int damage2 = (int)((float)spawnedPlayerMinionProjectileDamageValue / spawnedPlayerMinionDamageValue * player.MinionDamage()); + int damage2 = (int)(spawnedPlayerMinionProjectileDamageValue / spawnedPlayerMinionDamageValue * player.MinionDamage()); projectile.damage = damage2; } } @@ -605,7 +604,7 @@ namespace CalamityMod.Projectiles { if (projectile.timeLeft > 570) //all of these have a time left of 600 or 660 { - if (player.inventory[player.selectedItem].type == ItemID.BeesKnees) + if (player.ActiveItem().type == ItemID.BeesKnees) { projectile.magic = false; projectile.ranged = true; @@ -639,7 +638,7 @@ namespace CalamityMod.Projectiles { if (Main.npc[i].CanBeChasedBy(projectile, false)) { - float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); + float extraDistance = (float)(Main.npc[i].width / 2) + (Main.npc[i].height / 2); bool canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1); @@ -692,19 +691,19 @@ namespace CalamityMod.Projectiles if (projectile.owner == Main.myPlayer && player.ownedProjectileCounts[ProjectileID.Mushroom] < 30) { //Note: these don't count as true melee anymore but its useful code to keep around - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ProjectileID.SolarWhipSword) + if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || + projectile.type == ProjectileType() || projectile.type == ProjectileID.SolarWhipSword) { Vector2 vector24 = Main.OffsetsPlayerOnhand[Main.player[projectile.owner].bodyFrame.Y / 56] * 2f; if (Main.player[projectile.owner].direction != 1) { - vector24.X = (float)player.bodyFrame.Width - vector24.X; + vector24.X = player.bodyFrame.Width - vector24.X; } if (Main.player[projectile.owner].gravDir != 1f) { - vector24.Y = (float)player.bodyFrame.Height - vector24.Y; + vector24.Y = player.bodyFrame.Height - vector24.Y; } - vector24 -= new Vector2((float)(player.bodyFrame.Width - player.width), (float)(player.bodyFrame.Height - 42)) / 2f; + vector24 -= new Vector2(player.bodyFrame.Width - player.width, player.bodyFrame.Height - 42) / 2f; Vector2 newCenter = player.RotatedRelativePoint(player.position + vector24, true) + projectile.velocity; Projectile.NewProjectile(newCenter.X, newCenter.Y, 0f, 0f, ProjectileID.Mushroom, (int)(projectile.damage * 0.25), 0f, projectile.owner, 0f, 0f); @@ -718,25 +717,25 @@ namespace CalamityMod.Projectiles } } - if (modPlayer.nanotech && rogue && projectile.type != ModContent.ProjectileType() && projectile.type != ModContent.ProjectileType()) + if (modPlayer.nanotech && rogue && projectile.type != ProjectileType() && projectile.type != ProjectileType()) { if (counter % 30 == 0) { - if (projectile.owner == Main.myPlayer && Main.player[projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] < 25) + if (projectile.owner == Main.myPlayer && Main.player[projectile.owner].ownedProjectileCounts[ProjectileType()] < 25) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ProjectileType(), (int)(projectile.damage * 0.1), 0f, projectile.owner, 0f, 0f); } } } - if (modPlayer.dragonScales && rogue && projectile.type != ModContent.ProjectileType() && projectile.type != ModContent.ProjectileType()) + if (modPlayer.dragonScales && rogue && projectile.type != ProjectileType() && projectile.type != ProjectileType()) { if (counter % 50 == 0) { - if (projectile.owner == Main.myPlayer && Main.player[projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] < 15) + if (projectile.owner == Main.myPlayer && Main.player[projectile.owner].ownedProjectileCounts[ProjectileType()] < 15) { //spawn a dust that does 1/5th of the original damage - int projectileID = Projectile.NewProjectile(projectile.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi), ModContent.ProjectileType(), + int projectileID = Projectile.NewProjectile(projectile.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi), ProjectileType(), (int)(projectile.damage * 0.2), 0f, projectile.owner, 0f, 0f); } } @@ -744,22 +743,20 @@ namespace CalamityMod.Projectiles if (modPlayer.daedalusSplit && rogue) { - counter2++; - if (counter2 >= 30) + if (counter % 30 == 0) { - counter2 = 0; if (projectile.owner == Main.myPlayer && Main.player[projectile.owner].ownedProjectileCounts[90] < 30) { for (int num252 = 0; num252 < 2; num252++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + Vector2 value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); while (value15.X == 0f && value15.Y == 0f) { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); } value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int shard = Projectile.NewProjectile(projectile.oldPosition.X + (float)(projectile.width / 2), projectile.oldPosition.Y + (float)(projectile.height / 2), value15.X, value15.Y, 90, (int)(projectile.damage * 0.25), 0f, projectile.owner, 0f, 0f); + value15 *= Main.rand.Next(70, 101) * 0.1f; + int shard = Projectile.NewProjectile(projectile.oldPosition.X + (projectile.width / 2), projectile.oldPosition.Y + (projectile.height / 2), value15.X, value15.Y, 90, (int)(projectile.damage * 0.25), 0f, projectile.owner, 0f, 0f); Main.projectile[shard].ranged = false; } } @@ -792,45 +789,45 @@ namespace CalamityMod.Projectiles } } - if (!projectile.melee && (int)player.meleeEnchant > 0 && !projectile.noEnchantments) + if (!projectile.melee && player.meleeEnchant > 0 && !projectile.noEnchantments) { - if ((int)player.meleeEnchant == 7) //flask of party affects all types of weapons + if (player.meleeEnchant == 7) //flask of party affects all types of weapons { Vector2 velocity = projectile.velocity; - if ((double) velocity.Length() > 4.0) + if (velocity.Length() > 4.0) velocity *= 4f / velocity.Length(); if (Main.rand.NextBool(20)) { int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, Main.rand.Next(139, 143), velocity.X, velocity.Y, 0, new Color(), 1.2f); - Main.dust[index].velocity.X *= (float) (1.0 + (double) Main.rand.Next(-50, 51) * 0.01); - Main.dust[index].velocity.Y *= (float) (1.0 + (double) Main.rand.Next(-50, 51) * 0.01); - Main.dust[index].velocity.X += (float) Main.rand.Next(-50, 51) * 0.05f; - Main.dust[index].velocity.Y += (float) Main.rand.Next(-50, 51) * 0.05f; - Main.dust[index].scale *= (float) (1.0 + (double) Main.rand.Next(-30, 31) * 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); } if (Main.rand.NextBool(40)) { int Type = Main.rand.Next(276, 283); int index = Gore.NewGore(projectile.position, velocity, Type, 1f); - Main.gore[index].velocity.X *= (float) (1.0 + (double) Main.rand.Next(-50, 51) * 0.01); - Main.gore[index].velocity.Y *= (float) (1.0 + (double) Main.rand.Next(-50, 51) * 0.01); - Main.gore[index].scale *= (float) (1.0 + (double) Main.rand.Next(-20, 21) * 0.01); - Main.gore[index].velocity.X += (float) Main.rand.Next(-50, 51) * 0.05f; - Main.gore[index].velocity.Y += (float) Main.rand.Next(-50, 51) * 0.05f; + 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; } } } - if (rogue && (int)player.meleeEnchant > 0 && !projectile.noEnchantments) + if (rogue && player.meleeEnchant > 0 && !projectile.noEnchantments) { - if ((int)player.meleeEnchant == 1 && Main.rand.NextBool(3)) + if (player.meleeEnchant == 1 && Main.rand.NextBool(3)) { int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, 171, 0.0f, 0.0f, 100, new Color(), 1f); Main.dust[index].noGravity = true; Main.dust[index].fadeIn = 1.5f; Main.dust[index].velocity *= 0.25f; } - if ((int)player.meleeEnchant == 1) + if (player.meleeEnchant == 1) { if (Main.rand.NextBool(3)) { @@ -840,57 +837,57 @@ namespace CalamityMod.Projectiles Main.dust[index].velocity *= 0.25f; } } - else if ((int)player.meleeEnchant == 2) + else if (player.meleeEnchant == 2) { if (Main.rand.NextBool(2)) { - int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, 75, projectile.velocity.X * 0.2f + (float) (projectile.direction * 3), projectile.velocity.Y * 0.2f, 100, new Color(), 2.5f); + int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, 75, projectile.velocity.X * 0.2f + (projectile.direction * 3), projectile.velocity.Y * 0.2f, 100, new Color(), 2.5f); Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.7f; Main.dust[index].velocity.Y -= 0.5f; } } - else if ((int)player.meleeEnchant == 3) + else if (player.meleeEnchant == 3) { if (Main.rand.NextBool(2)) { - int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, projectile.velocity.X * 0.2f + (float) (projectile.direction * 3), projectile.velocity.Y * 0.2f, 100, new Color(), 2.5f); + int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, projectile.velocity.X * 0.2f + (projectile.direction * 3), projectile.velocity.Y * 0.2f, 100, new Color(), 2.5f); Main.dust[index].noGravity = true; Main.dust[index].velocity *= 0.7f; Main.dust[index].velocity.Y -= 0.5f; } } - else if ((int)player.meleeEnchant == 4) + else if (player.meleeEnchant == 4) { if (Main.rand.NextBool(2)) { - int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, 57, projectile.velocity.X * 0.2f + (float) (projectile.direction * 3), projectile.velocity.Y * 0.2f, 100, new Color(), 1.1f); + int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, 57, projectile.velocity.X * 0.2f + (projectile.direction * 3), projectile.velocity.Y * 0.2f, 100, new Color(), 1.1f); Main.dust[index].noGravity = true; Main.dust[index].velocity.X /= 2f; Main.dust[index].velocity.Y /= 2f; } } - else if ((int)player.meleeEnchant == 5) + else if (player.meleeEnchant == 5) { if (Main.rand.NextBool(2)) { int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, 169, 0.0f, 0.0f, 100, new Color(), 1f); - Main.dust[index].velocity.X += (float) projectile.direction; + Main.dust[index].velocity.X += projectile.direction; Main.dust[index].velocity.Y += 0.2f; Main.dust[index].noGravity = true; } } - else if ((int)player.meleeEnchant == 6) + else if (player.meleeEnchant == 6) { if (Main.rand.NextBool(2)) { int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, 0.0f, 0.0f, 100, new Color(), 1f); - Main.dust[index].velocity.X += (float) projectile.direction; + Main.dust[index].velocity.X += projectile.direction; Main.dust[index].velocity.Y += 0.2f; Main.dust[index].noGravity = true; } } - else if ((int)player.meleeEnchant == 8 && Main.rand.NextBool(4)) + else if (player.meleeEnchant == 8 && Main.rand.NextBool(4)) { int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, 46, 0.0f, 0.0f, 100, new Color(), 1f); Main.dust[index].noGravity = true; @@ -905,9 +902,9 @@ namespace CalamityMod.Projectiles if (modPlayer.moonCrown && !modPlayer.nanotech) { //Summon moon sigils infrequently - if (Main.rand.NextBool(300) && projectile.type != ModContent.ProjectileType() && projectile.type != ModContent.ProjectileType()) + if (Main.rand.NextBool(300) && projectile.type != ProjectileType() && projectile.type != ProjectileType()) { - Projectile.NewProjectile(projectile.position, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.2), 0, projectile.owner); + Projectile.NewProjectile(projectile.position, Vector2.Zero, ProjectileType(), (int)(projectile.damage * 0.2), 0, projectile.owner); } } } @@ -960,7 +957,6 @@ namespace CalamityMod.Projectiles } #endregion - // TODO -- there are a LOT of returns here which should be breaks or gotos out of if statements #region OnHitNPC public override void OnHitNPC(Projectile projectile, NPC target, int damage, float knockback, bool crit) { @@ -973,11 +969,12 @@ namespace CalamityMod.Projectiles { target.immune[projectile.owner] = 10; } + //flask of party affects all types of weapons, !projectile.melee is to prevent double flask effects - if (!projectile.melee && (int) player.meleeEnchant == 7) + if (!projectile.melee && player.meleeEnchant == 7) Projectile.NewProjectile(target.Center.X, target.Center.Y, target.velocity.X, target.velocity.Y, ProjectileID.ConfettiMelee, 0, 0f, projectile.owner, 0f, 0f); - if (rogue && stealthStrike && modPlayer.dragonScales && CalamityUtils.CountProjectiles(ModContent.ProjectileType()) < 2) + if (rogue && stealthStrike && modPlayer.dragonScales && CalamityUtils.CountProjectiles(ProjectileType()) < 2) { int projTileX = (int)(projectile.Center.X / 16f); int projTileY = (int)(projectile.Center.Y / 16f); @@ -1001,13 +998,13 @@ namespace CalamityMod.Projectiles for (int x = projTileX; x < projTileX + distance; x++) { Tile tile = Main.tile[projTileX, projTileY]; - if (tile.active() && (Main.tileSolid[(int)tile.type] || tile.liquid != 0)) + if (tile.active() && (Main.tileSolid[tile.type] || tile.liquid != 0)) { projTileX = x; break; } } - int projectileIndex = Projectile.NewProjectile((float)(projTileX * 16 + 8), (float)(projTileY * 16 - 24), 0f, 0f, ModContent.ProjectileType(), 420, 15f, Main.myPlayer, 16f, 16f); + int projectileIndex = Projectile.NewProjectile(projTileX * 16 + 8, projTileY * 16 - 24, 0f, 0f, ProjectileType(), 420, 15f, Main.myPlayer, 16f, 16f); Main.projectile[projectileIndex].Calamity().forceRogue = true; Main.projectile[projectileIndex].netUpdate = true; Main.projectile[projectileIndex].localNPCHitCooldown = 1; @@ -1024,15 +1021,15 @@ namespace CalamityMod.Projectiles if (player.setNebula && player.nebulaCD == 0 && Main.rand.Next(3) == 0) { player.nebulaCD = 30; - int boosterType = Utils.SelectRandom(Main.rand, new int[] + int boosterType = Utils.SelectRandom(Main.rand, new int[] { ItemID.NebulaPickup1, ItemID.NebulaPickup2, ItemID.NebulaPickup3 }); int nebulaBooster = Item.NewItem((int)target.position.X, (int)target.position.Y, target.width, target.height, boosterType, 1, false, 0, false, false); - Main.item[nebulaBooster].velocity.Y = (float)Main.rand.Next(-20, 1) * 0.2f; - Main.item[nebulaBooster].velocity.X = (float)Main.rand.Next(10, 31) * 0.2f * (float)projectile.direction; + Main.item[nebulaBooster].velocity.Y = Main.rand.Next(-20, 1) * 0.2f; + Main.item[nebulaBooster].velocity.X = Main.rand.Next(10, 31) * 0.2f * projectile.direction; if (Main.netMode == 1) { NetMessage.SendData(21, -1, -1, null, nebulaBooster, 0f, 0f, 0f, 0, 0, 0); @@ -1040,156 +1037,138 @@ namespace CalamityMod.Projectiles } } - // Increases the degree to which Spectre Healing set contributes to the lifesteal cap - if (player.ghostHeal) + if (Main.player[Main.myPlayer].lifeSteal > 0f && target.canGhostHeal && target.type != NPCID.TargetDummy && target.type != NPCType()) { - if (Main.player[Main.myPlayer].lifeSteal <= 0f) + // Increases the degree to which Spectre Healing set contributes to the lifesteal cap + if (player.ghostHeal) { - return; + float num = 0.1f; + num -= projectile.numHits * 0.025f; + if (num < 0f) + num = 0f; + + float num2 = damage * num; + Main.player[Main.myPlayer].lifeSteal -= num2; } - float num = 0.1f; - num -= (float)projectile.numHits * 0.05f; - if (num < 0f) + + // Increases the degree to which Vampire Knives contribute to the lifesteal cap + if (projectile.type == ProjectileID.VampireKnife) { - num = 0f; + float num = damage * 0.0375f; + if (num < 0f) + num = 0f; + + Main.player[Main.myPlayer].lifeSteal -= num; + } + + if (modPlayer.vampiricTalisman && rogue && crit) + { + float heal = MathHelper.Clamp(damage * 0.015f, 0f, 6f); + Main.player[Main.myPlayer].lifeSteal -= heal * 2f; + Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, ProjectileID.VampireHeal, 0, 0f, projectile.owner, projectile.owner, heal); + } + + if ((modPlayer.bloodyGlove || modPlayer.electricianGlove) && rogue && stealthStrike) + { + player.statLife += 1; + player.HealEffect(1); + } + + if (modPlayer.auricSet) + { + float healMult = 0.05f; + healMult -= projectile.numHits * 0.025f; + float heal = projectile.damage * healMult; + + if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) + goto OTHEREFFECTS; + + SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 1.5f); + } + else if (modPlayer.silvaSet) + { + float healMult = 0.03f; + healMult -= projectile.numHits * 0.015f; + float heal = projectile.damage * healMult; + + if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) + goto OTHEREFFECTS; + + SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 1.5f); + } + else if (projectile.magic) + { + if (modPlayer.godSlayerMage) + { + float healMult = 0.06f; + healMult -= projectile.numHits * 0.015f; + float heal = projectile.damage * healMult; + + if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) + goto OTHEREFFECTS; + + SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 1.5f); + } + else if (modPlayer.tarraMage) + { + if (modPlayer.tarraMageHealCooldown <= 0) + { + modPlayer.tarraMageHealCooldown = 90; + + float healMult = 0.1f; + healMult -= projectile.numHits * 0.05f; + float heal = projectile.damage * healMult; + + if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) + goto OTHEREFFECTS; + + Main.player[Main.myPlayer].lifeSteal -= heal * 6f; + int healAmount = (int)heal; + player.statLife += healAmount; + player.HealEffect(healAmount); + + if (player.statLife > player.statLifeMax2) + player.statLife = player.statLifeMax2; + } + } + else if (modPlayer.ataxiaMage) + { + float healMult = 0.1f; + healMult -= projectile.numHits * 0.05f; + float heal = projectile.damage * healMult; + + if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) + goto OTHEREFFECTS; + + SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 1.5f); + } + else if (modPlayer.manaOverloader) + { + float healMult = 0.2f; + healMult -= projectile.numHits * 0.05f; + float heal = projectile.damage * healMult * (player.statMana / (float)player.statManaMax2); + + if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) + goto OTHEREFFECTS; + + SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 1.5f); + } } - float num2 = (float)damage * num; - Main.player[Main.myPlayer].lifeSteal -= num2; } - // Increases the degree to which Vampire Knives contribute to the lifesteal cap - if (projectile.type == ProjectileID.VampireKnife) - { - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - { - return; - } - float num = (float)damage * 0.0375f; - if (num < 0f) - { - num = 0f; - } - Main.player[Main.myPlayer].lifeSteal -= num; - } - - if (modPlayer.vampiricTalisman && rogue && crit) - { - if (target.type == NPCID.TargetDummy) - return; - - float heal = (float)damage * 0.015f; - if ((int)heal == 0) - return; - if ((int)heal > 6) - heal = 6; - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - return; - - Main.player[Main.myPlayer].lifeSteal -= heal * 2f; - int owner = projectile.owner; - Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, ProjectileID.VampireHeal, 0, 0f, projectile.owner, (float)owner, heal); - } - - if ((modPlayer.bloodyGlove || modPlayer.electricianGlove) && rogue && stealthStrike) - { - if (target.type == NPCID.TargetDummy || !target.canGhostHeal) - { - return; - } - player.statLife += 1; - player.HealEffect(1); - } + OTHEREFFECTS: if (modPlayer.alchFlask && (projectile.magic || rogue || projectile.melee || projectile.minion || projectile.ranged || projectile.sentry || CalamityMod.projectileMinionList.Contains(projectile.type) || ProjectileID.Sets.MinionShot[projectile.type] || ProjectileID.Sets.SentryShot[projectile.type]) && - player.ownedProjectileCounts[ModContent.ProjectileType()] < 6) + player.ownedProjectileCounts[ProjectileType()] < 6) { - int newDamage = (int)(projectile.damage * 0.25); - if (newDamage > 30) - { - newDamage = (int)((projectile.damage * 0.25 - 30) * 0.1) + 30; - } - int plague = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), newDamage, 0f, projectile.owner, 0f, 0f); + int plague = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.25, 30), 0f, projectile.owner, 0f, 0f); Main.projectile[plague].Calamity().forceTypeless = false; } if (modPlayer.reaverBlast && projectile.melee) { - int newDamage = (int)(projectile.damage * 0.2); - if (newDamage > 30) - { - newDamage = (int)((projectile.damage * 0.2 - 30) * 0.1) + 30; - } - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), newDamage, 0f, projectile.owner, 0f, 0f); - } - - if (modPlayer.auricSet && target.canGhostHeal) - { - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - { - return; - } - float num11 = 0.05f; - num11 -= (float)projectile.numHits * 0.025f; - if (num11 <= 0f) - { - return; - } - float num12 = (float)projectile.damage * num11; - if ((int)num12 <= 0) - { - return; - } - Main.player[Main.myPlayer].lifeSteal -= num12 * 1.5f; - float num13 = 0f; - int num14 = projectile.owner; - for (int i = 0; i < Main.maxPlayers; i++) - { - if (Main.player[i].active && !Main.player[i].dead && ((!player.hostile && !Main.player[i].hostile) || player.team == Main.player[i].team)) - { - float num15 = Math.Abs(Main.player[i].position.X + (float)(Main.player[i].width / 2) - projectile.position.X + (float)(projectile.width / 2)) + Math.Abs(Main.player[i].position.Y + (float)(Main.player[i].height / 2) - projectile.position.Y + (float)(projectile.height / 2)); - if (num15 < 1200f && (float)(Main.player[i].statLifeMax2 - Main.player[i].statLife) > num13) - { - num13 = (float)(Main.player[i].statLifeMax2 - Main.player[i].statLife); - num14 = i; - } - } - } - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, projectile.owner, (float)num14, num12); - } - else if (modPlayer.silvaSet && target.canGhostHeal) - { - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - { - return; - } - float num11 = 0.03f; - num11 -= (float)projectile.numHits * 0.015f; - if (num11 <= 0f) - { - return; - } - float num12 = (float)projectile.damage * num11; - if ((int)num12 <= 0) - { - return; - } - Main.player[Main.myPlayer].lifeSteal -= num12 * 1.5f; - float num13 = 0f; - int num14 = projectile.owner; - for (int i = 0; i < Main.maxPlayers; i++) - { - if (Main.player[i].active && !Main.player[i].dead && ((!player.hostile && !Main.player[i].hostile) || player.team == Main.player[i].team)) - { - float num15 = Math.Abs(Main.player[i].position.X + (float)(Main.player[i].width / 2) - projectile.position.X + (float)(projectile.width / 2)) + Math.Abs(Main.player[i].position.Y + (float)(Main.player[i].height / 2) - projectile.position.Y + (float)(projectile.height / 2)); - if (num15 < 1200f && (float)(Main.player[i].statLifeMax2 - Main.player[i].statLife) > num13) - { - num13 = (float)(Main.player[i].statLifeMax2 - Main.player[i].statLife); - num14 = i; - } - } - } - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, projectile.owner, (float)num14, num12); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.2, 30), 0f, projectile.owner, 0f, 0f); } if (projectile.magic) @@ -1199,8 +1178,8 @@ namespace CalamityMod.Projectiles Main.PlaySound(29, (int)projectile.position.X, (int)projectile.position.Y, 103); projectile.position = projectile.Center; projectile.width = projectile.height = 96; - projectile.position.X -= (float)(projectile.width / 2); - projectile.position.Y -= (float)(projectile.height / 2); + projectile.position.X -= projectile.width / 2; + projectile.position.Y -= projectile.height / 2; for (int num193 = 0; num193 < 3; num193++) { Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 157, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.5f); @@ -1220,236 +1199,113 @@ namespace CalamityMod.Projectiles projectile.Damage(); } - if (modPlayer.tarraMage && target.canGhostHeal) - { - if (modPlayer.tarraMageHealCooldown <= 0) - { - if (Main.player[Main.myPlayer].lifeSteal <= 0f) + if (modPlayer.reaverBurst) + { + int num251 = Main.rand.Next(2, 5); + for (int num252 = 0; num252 < num251; num252++) + { + Vector2 value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + while (value15.X == 0f && value15.Y == 0f) { - return; + value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); } - modPlayer.tarraMageHealCooldown = 90; - float num11 = 0.03f; - num11 -= (float)projectile.numHits * 0.015f; - if (num11 <= 0f) - { - return; - } - float num12 = (float)projectile.damage * num11; - if ((int)num12 <= 0) - { - return; - } - Main.player[Main.myPlayer].lifeSteal -= num12 * 1.5f; - int healAmount = modPlayer.auricSet ? projectile.damage / 100 : projectile.damage / 50; - player.statLife += healAmount; - player.HealEffect(healAmount); - if (player.statLife > player.statLifeMax2) - { - player.statLife = player.statLifeMax2; - } - } - } - - if (modPlayer.reaverBurst) - { - int num251 = Main.rand.Next(2, 5); - for (int num252 = 0; num252 < num251; num252++) - { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int newDamage = (int)(projectile.damage * 0.15); - if (newDamage > 15) - { - newDamage = (int)((projectile.damage * 0.15 - 15) * 0.1) + 15; - } - int proj = Projectile.NewProjectile(projectile.oldPosition.X + (float)(projectile.width / 2), projectile.oldPosition.Y + (float)(projectile.height / 2), value15.X, value15.Y, 569 + Main.rand.Next(3), newDamage, 0f, projectile.owner, 0f, 0f); - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = 30; - } - } - else if (modPlayer.ataxiaMage && modPlayer.ataxiaDmg <= 0) - { - SpawnOrb(projectile, 1.25f, ModContent.ProjectileType(), 800f, 20f); + value15.Normalize(); + value15 *= Main.rand.Next(70, 101) * 0.1f; + int proj = Projectile.NewProjectile(projectile.oldPosition.X + (projectile.width / 2), projectile.oldPosition.Y + (projectile.height / 2), value15.X, value15.Y, 569 + Main.rand.Next(3), CalamityUtils.DamageSoftCap(projectile.damage * 0.15, 15), 0f, projectile.owner, 0f, 0f); + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 30; + } + } + else if (modPlayer.ataxiaMage && modPlayer.ataxiaDmg <= 0) + { + SpawnOrb(projectile, 1.25f, ProjectileType(), 800f, 20f); int num = (int)(projectile.damage * 0.5f); - modPlayer.ataxiaDmg += (float)num; - if (target.canGhostHeal) - { - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - { - return; - } - float num11 = 0.1f; //0.2 - num11 -= (float)projectile.numHits * 0.05f; //0.05 - if (num11 <= 0f) - { - return; - } - float num12 = (float)projectile.damage * num11; - if ((int)num12 <= 0) - { - return; - } - Main.player[Main.myPlayer].lifeSteal -= num12 * 1.5f; - float num13 = 0f; - int num14 = projectile.owner; - for (int i = 0; i < Main.maxPlayers; i++) - { - if (Main.player[i].active && !Main.player[i].dead && ((!player.hostile && !Main.player[i].hostile) || player.team == Main.player[i].team)) - { - float num15 = Math.Abs(Main.player[i].position.X + (float)(Main.player[i].width / 2) - projectile.position.X + (float)(projectile.width / 2)) + Math.Abs(Main.player[i].position.Y + (float)(Main.player[i].height / 2) - projectile.position.Y + (float)(projectile.height / 2)); - if (num15 < 1200f && (float)(Main.player[i].statLifeMax2 - Main.player[i].statLife) > num13) - { - num13 = (float)(Main.player[i].statLifeMax2 - Main.player[i].statLife); - num14 = i; - } - } - } - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, projectile.owner, (float)num14, num12); - } - } - else if (modPlayer.godSlayerMage && modPlayer.godSlayerDmg <= 0) - { - SpawnOrb(projectile, modPlayer.auricSet ? 2f : 1.5f, ModContent.ProjectileType(), 800f, 20f); + modPlayer.ataxiaDmg += num; + } + else if (modPlayer.godSlayerMage && modPlayer.godSlayerDmg <= 0) + { + SpawnOrb(projectile, modPlayer.auricSet ? 2f : 1.5f, ProjectileType(), 800f, 20f); int num = (int)(projectile.damage * 0.5f); - modPlayer.godSlayerDmg += (float)num; - if (target.canGhostHeal) - { - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - { - return; - } - float num11 = modPlayer.auricSet ? 0.03f : 0.06f; //0.2 - num11 -= (float)projectile.numHits * 0.015f; //0.05 - if (num11 <= 0f) - { - return; - } - float num12 = (float)projectile.damage * num11; - if ((int)num12 <= 0) - { - return; - } - Main.player[Main.myPlayer].lifeSteal -= num12 * 1.5f; - float num13 = 0f; - int num14 = projectile.owner; - for (int i = 0; i < Main.maxPlayers; i++) - { - if (Main.player[i].active && !Main.player[i].dead && ((!player.hostile && !Main.player[i].hostile) || player.team == Main.player[i].team)) - { - float num15 = Math.Abs(Main.player[i].position.X + (float)(Main.player[i].width / 2) - projectile.position.X + (float)(projectile.width / 2)) + Math.Abs(Main.player[i].position.Y + (float)(Main.player[i].height / 2) - projectile.position.Y + (float)(projectile.height / 2)); - if (num15 < 1200f && (float)(Main.player[i].statLifeMax2 - Main.player[i].statLife) > num13) - { - num13 = (float)(Main.player[i].statLifeMax2 - Main.player[i].statLife); - num14 = i; - } - } - } - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, projectile.owner, (float)num14, num12); - } - } + modPlayer.godSlayerDmg += num; + } } else if (projectile.melee) { - if (modPlayer.ataxiaGeyser && player.ownedProjectileCounts[ModContent.ProjectileType()] < 3) + if (modPlayer.ataxiaGeyser && player.ownedProjectileCounts[ProjectileType()] < 3) { - int newDamage = (int)(projectile.damage * 0.15); - if (newDamage > 35) - { - newDamage = (int)((projectile.damage * 0.15 - 35) * 0.1) + 35; - } - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), newDamage, 0f, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.15, 35), 0f, projectile.owner, 0f, 0f); } } else if (rogue) { - if (modPlayer.xerocSet && modPlayer.xerocDmg <= 0 && player.ownedProjectileCounts[ModContent.ProjectileType()] < 3 && player.ownedProjectileCounts[ModContent.ProjectileType()] < 3) + if (modPlayer.xerocSet && modPlayer.xerocDmg <= 0 && player.ownedProjectileCounts[ProjectileType()] < 3 && player.ownedProjectileCounts[ProjectileType()] < 3) { - if (Main.rand.NextBool(5)) + switch (Main.rand.Next(5)) { - SpawnOrb(projectile, 1.6f, ModContent.ProjectileType(), 800f, Main.rand.Next(15, 30)); - int num = (int)(projectile.damage * 0.5f); - modPlayer.xerocDmg += (float)num; - } - else if (Main.rand.NextBool(4)) - { - SpawnOrb(projectile, 1.25f, ModContent.ProjectileType(), 800f, 30f); - int num = (int)(projectile.damage * 0.5f); - modPlayer.xerocDmg += (float)num; - if (target.canGhostHeal) - { - if (Main.player[Main.myPlayer].lifeSteal <= 0f) + case 0: + + SpawnOrb(projectile, 1.6f, ProjectileType(), 800f, Main.rand.Next(15, 30)); + int num = (int)(projectile.damage * 0.5f); + modPlayer.xerocDmg += num; + + break; + + case 1: + + SpawnOrb(projectile, 1.25f, ProjectileType(), 800f, 30f); + int num2 = (int)(projectile.damage * 0.5f); + modPlayer.xerocDmg += num2; + + if (target.canGhostHeal && Main.player[Main.myPlayer].lifeSteal > 0f) { - return; + float healMult = 0.06f; + healMult -= projectile.numHits * 0.015f; + float heal = projectile.damage * healMult; + + if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) + goto SKIPXEROC; + + SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 1.5f); } - float num11 = 0.1f; - num11 -= (float)projectile.numHits * 0.05f; - if (num11 <= 0f) - { - return; - } - float num12 = (float)projectile.damage * num11; - if ((int)num12 <= 0) - { - return; - } - Main.player[Main.myPlayer].lifeSteal -= num12 * 1.5f; - float num13 = 0f; - int num14 = projectile.owner; - for (int i = 0; i < Main.maxPlayers; i++) - { - if (Main.player[i].active && !Main.player[i].dead && ((!player.hostile && !Main.player[i].hostile) || player.team == Main.player[i].team)) - { - float num15 = Math.Abs(Main.player[i].position.X + (float)(Main.player[i].width / 2) - projectile.position.X + (float)(projectile.width / 2)) + Math.Abs(Main.player[i].position.Y + (float)(Main.player[i].height / 2) - projectile.position.Y + (float)(projectile.height / 2)); - if (num15 < 1200f && (float)(Main.player[i].statLifeMax2 - Main.player[i].statLife) > num13) - { - num13 = (float)(Main.player[i].statLifeMax2 - Main.player[i].statLife); - num14 = i; - } - } - } - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, projectile.owner, (float)num14, num12); - } - } - else if (Main.rand.NextBool(3)) - { - int newDamage = (int)(projectile.damage * 0.15); - if (newDamage > 40) - { - newDamage = (int)((projectile.damage * 0.15 - 40) * 0.1) + 40; - } - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), newDamage, 0f, projectile.owner, 0f, 0f); - } - else if (Main.rand.NextBool(2)) - { - int newDamage = (int)(projectile.damage * 0.2); - if (newDamage > 40) - { - newDamage = (int)((projectile.damage * 0.2 - 40) * 0.1) + 40; - } - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), newDamage, 0f, projectile.owner, 0f, 0f); - } - else - { - SpawnOrb(projectile, 1.2f, ModContent.ProjectileType(), 800f, 15f); - int num = (int)(projectile.damage * 0.5f); - modPlayer.xerocDmg += (float)num; + + break; + + case 2: + + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.15, 40), 0f, projectile.owner, 0f, 0f); + + break; + + case 3: + + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.2, 40), 0f, projectile.owner, 0f, 0f); + + break; + + case 4: + + SpawnOrb(projectile, 1.2f, ProjectileType(), 800f, 15f); + int num3 = (int)(projectile.damage * 0.5f); + modPlayer.xerocDmg += num3; + + break; + + default: + break; } } + + SKIPXEROC: + if (modPlayer.featherCrown && stealthStrike && modPlayer.featherCrownCooldown <= 0) { for (int i = 0; i < 6; i++) { - Vector2 pos = new Vector2(target.Center.X + (float)target.width * 0.5f + (float)Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + Vector2 pos = new Vector2(target.Center.X + target.width * 0.5f + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); float speedX = (target.Center.X - pos.X) / 30f; float speedY = (target.Center.Y - pos.Y) * 8; int dmg = (int)(15 + (projectile.damage * 0.05f)); - int feather = Projectile.NewProjectile(pos.X, pos.Y, speedX, speedY, ModContent.ProjectileType(), dmg, 3, projectile.owner, 0f, (float)Main.rand.Next(15)); + int feather = Projectile.NewProjectile(pos.X, pos.Y, speedX, speedY, ProjectileType(), dmg, 3, projectile.owner, 0f, Main.rand.Next(15)); Main.projectile[feather].Calamity().forceRogue = true; modPlayer.featherCrownCooldown = 15; } @@ -1459,9 +1315,9 @@ namespace CalamityMod.Projectiles { for (int i = 0; i < 6; i++) { - Vector2 pos = new Vector2(target.Center.X + (float)target.width * 0.5f + (float)Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + Vector2 pos = new Vector2(target.Center.X + target.width * 0.5f + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); Vector2 velocity = (target.Center - pos) / 10f; - float AI1 = (float)Main.rand.Next(3); + float AI1 = Main.rand.Next(3); int dmg = (int)(150 + (projectile.damage * 0.05f)); int flare = Projectile.NewProjectile(pos, velocity, ProjectileID.LunarFlare, dmg, 3, projectile.owner, 0f, AI1); Main.projectile[flare].Calamity().forceRogue = true; @@ -1473,10 +1329,10 @@ namespace CalamityMod.Projectiles { for (int i = 0; i < 6; i++) { - Vector2 pos = new Vector2(target.Center.X + (float)target.width * 0.5f + (float)Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + Vector2 pos = new Vector2(target.Center.X + target.width * 0.5f + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); Vector2 velocity = (target.Center - pos) / 40f; int dmg = (int)(1000 + (projectile.damage * 0.05f)); - int flare = Projectile.NewProjectile(pos, velocity, ModContent.ProjectileType(),dmg, 3f, projectile.owner, 0f, 0f); + int flare = Projectile.NewProjectile(pos, velocity, ProjectileType(),dmg, 3f, projectile.owner, 0f, 0f); Main.projectile[flare].Calamity().rogue = true; modPlayer.nanoFlareCooldown = 15; } @@ -1486,17 +1342,17 @@ namespace CalamityMod.Projectiles { for (int index2 = 0; index2 < 6; index2++) { - float xVector = (float)Main.rand.Next(-35, 36) * 0.02f; - float yVector = (float)Main.rand.Next(-35, 36) * 0.02f; + float xVector = Main.rand.Next(-35, 36) * 0.02f; + float yVector = Main.rand.Next(-35, 36) * 0.02f; xVector *= 10f; yVector *= 10f; int dmg = (int)(75 + (projectile.damage * 0.05f)); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, xVector, yVector, ModContent.ProjectileType(), dmg, projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, xVector, yVector, ProjectileType(), dmg, projectile.knockBack, projectile.owner, 0f, 0f); modPlayer.forbiddenCooldown = 15; } } - if (modPlayer.corrosiveSpine && projectile.type != ModContent.ProjectileType() && projectile.type != ModContent.ProjectileType() && projectile.type != ModContent.ProjectileType()) + if (modPlayer.corrosiveSpine && projectile.type != ProjectileType() && projectile.type != ProjectileType() && projectile.type != ProjectileType()) { for (int i = 0; i < 3; i++) { @@ -1506,13 +1362,13 @@ namespace CalamityMod.Projectiles switch (Main.rand.Next(15)) { case 0: - type = ModContent.ProjectileType(); + type = ProjectileType(); break; case 1: - type = ModContent.ProjectileType(); + type = ProjectileType(); break; case 2: - type = ModContent.ProjectileType(); + type = ProjectileType(); break; } // Should never happen, but just in case- @@ -1531,12 +1387,12 @@ namespace CalamityMod.Projectiles { if (modPlayer.profanedCrystalBuffs || (modPlayer.pArtifact && !modPlayer.profanedCrystal)) { - target.AddBuff(ModContent.BuffType(), modPlayer.profanedCrystalBuffs ? 600 : 300); + target.AddBuff(BuffType(), modPlayer.profanedCrystalBuffs ? 600 : 300); } if (modPlayer.tearMinions) { - target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(BuffType(), 60); } if (modPlayer.shadowMinions) @@ -1556,8 +1412,8 @@ namespace CalamityMod.Projectiles if (modPlayer.starTaintedGenerator) { - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffType(), 180); + target.AddBuff(BuffType(), 180); } // Fearmonger set's colossal life regeneration @@ -1570,20 +1426,21 @@ namespace CalamityMod.Projectiles if (modPlayer.godSlayerSummon && modPlayer.godSlayerDmg <= 0) { - SpawnOrb(projectile, 2f, ModContent.ProjectileType(), 800f, 15f, true); + SpawnOrb(projectile, 2f, ProjectileType(), 800f, 15f, true); int num = (int)(projectile.damage * 0.5f); - modPlayer.godSlayerDmg += (float)num; + modPlayer.godSlayerDmg += num; } //Priorities: Nucleogenesis => Starbuster Core => Nuclear Rod => Jelly-Charged Battery List summonExceptionList = new List() { - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType() + ProjectileType(), + ProjectileType(), + ProjectileType(), + ProjectileType(), + ProjectileType() }; + if (summonExceptionList.TrueForAll(x => projectile.type != x)) { if (modPlayer.jellyDmg <= 0) @@ -1592,12 +1449,7 @@ namespace CalamityMod.Projectiles { if (Main.rand.NextBool(4)) { - int newDamage = (int)(projectile.damage * 0.25); - if (newDamage > 100) - { - newDamage = (int)((projectile.damage * 0.25 - 100) * 0.1) + 100; - } - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), newDamage, projectile.knockBack * 0.25f, projectile.owner); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.25, 100), projectile.knockBack * 0.25f, projectile.owner); modPlayer.jellyDmg = 20f; } } @@ -1606,13 +1458,8 @@ namespace CalamityMod.Projectiles if (Main.rand.NextBool(3)) { int cap = modPlayer.starTaintedGenerator ? 75 : 60; - int newDamage = (int)(projectile.damage * 0.5); - if (newDamage > cap) - { - newDamage = (int)((projectile.damage * 0.5 - cap) * 0.1) + cap; - } - int boom = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), - newDamage, 3f, projectile.owner); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), + CalamityUtils.DamageSoftCap(projectile.damage * 0.5, cap), 3f, projectile.owner); modPlayer.jellyDmg = 20f; } } @@ -1620,21 +1467,16 @@ namespace CalamityMod.Projectiles { if (Main.rand.NextBool(3)) { - int newDamage = (int)(projectile.damage * 0.25); - if (newDamage > 40) - { - newDamage = (int)((projectile.damage * 0.25 - 40) * 0.1) + 40; - } - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), - newDamage, 0f, projectile.owner); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), + CalamityUtils.DamageSoftCap(projectile.damage * 0.25, 40), 0f, projectile.owner); modPlayer.jellyDmg = 20f; } } else if (modPlayer.jellyChargedBattery) { - SpawnOrb(projectile, 1.05f, ModContent.ProjectileType(), 800f, 15f); + SpawnOrb(projectile, 1.05f, ProjectileType(), 800f, 15f); int num = (int)(projectile.damage * 0.5f); - modPlayer.jellyDmg += (float)num; + modPlayer.jellyDmg += num; } } @@ -1646,7 +1488,7 @@ namespace CalamityMod.Projectiles Vector2 spawnPosition = target.Center - new Vector2(0f, 920f).RotatedByRandom(0.3f); float speed = Main.rand.NextFloat(17f, 23f); Projectile.NewProjectile(spawnPosition, Vector2.Normalize(target.Center - spawnPosition) * speed, - ModContent.ProjectileType(), projectile.damage / 3, 3f, projectile.owner); + ProjectileType(), projectile.damage / 3, 3f, projectile.owner); } } } @@ -1654,24 +1496,19 @@ namespace CalamityMod.Projectiles if (projectile.ranged) { - if (modPlayer.tarraRanged && Main.rand.Next(0, 100) >= 88 && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 20 && (projectile.timeLeft <= 2 || projectile.penetrate <= 1)) + if (modPlayer.tarraRanged && Main.rand.Next(0, 100) >= 88 && player.ownedProjectileCounts[ProjectileType()] <= 20 && (projectile.timeLeft <= 2 || projectile.penetrate <= 1)) { int num251 = Main.rand.Next(2, 4); for (int num252 = 0; num252 < num251; num252++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + Vector2 value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); while (value15.X == 0f && value15.Y == 0f) { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); } value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int newDamage = (int)(projectile.damage * 0.33); - if (newDamage > 65) - { - newDamage = (int)((projectile.damage * 0.33 - 65) * 0.1) + 65; - } - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), newDamage, 0f, projectile.owner, 0f, 0f); + value15 *= Main.rand.Next(70, 101) * 0.1f; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.33, 65), 0f, projectile.owner, 0f, 0f); } } } @@ -1731,7 +1568,7 @@ namespace CalamityMod.Projectiles { spriteEffects = SpriteEffects.FlipHorizontally; } - Vector2 vector11 = new Vector2((float)(texture.Width / 2), (float)(texture.Height / Main.projFrames[projectile.type] / 2)); + Vector2 vector11 = new Vector2(texture.Width / 2, texture.Height / Main.projFrames[projectile.type] / 2); Color color9 = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, projectile.alpha); Color alpha15 = projectile.GetAlpha(color9); for (int num213 = 0; num213 < 4; num213++) @@ -1747,7 +1584,7 @@ namespace CalamityMod.Projectiles { position9.X = Main.player[Main.myPlayer].Center.X - num214; } - position9.X -= (float)(projectile.width / 2); + position9.X -= projectile.width / 2; if (num213 == 0 || num213 == 1) { position9.Y = Main.player[Main.myPlayer].Center.Y + num215; @@ -1758,9 +1595,9 @@ namespace CalamityMod.Projectiles } int frames = texture.Height / Main.projFrames[projectile.type]; int y = frames * projectile.frame; - position9.Y -= (float)(projectile.height / 2); + position9.Y -= projectile.height / 2; Main.spriteBatch.Draw(texture, - new Vector2(position9.X - Main.screenPosition.X + (float)(projectile.width / 2) - (float)texture.Width * projectile.scale / 2f + vector11.X * projectile.scale, position9.Y - Main.screenPosition.Y + (float)projectile.height - (float)texture.Height * projectile.scale / (float)Main.projFrames[projectile.type] + 4f + vector11.Y * projectile.scale + projectile.gfxOffY), + new Vector2(position9.X - Main.screenPosition.X + (projectile.width / 2) - texture.Width * projectile.scale / 2f + vector11.X * projectile.scale, position9.Y - Main.screenPosition.Y + projectile.height - texture.Height * projectile.scale / Main.projFrames[projectile.type] + 4f + vector11.Y * projectile.scale + projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y, texture.Width, frames)), alpha15, projectile.rotation, vector11, projectile.scale, spriteEffects, 0f); } } @@ -1790,7 +1627,7 @@ namespace CalamityMod.Projectiles for (int i = 0; i < projectile.oldPos.Length; i++) { Vector2 drawPos = projectile.oldPos[i] + centerOffset - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); - Color color = projectile.GetAlpha(lightColor) * ((float)(projectile.oldPos.Length - i) / (float)projectile.oldPos.Length); + Color color = projectile.GetAlpha(lightColor) * ((projectile.oldPos.Length - i) / projectile.oldPos.Length); Main.spriteBatch.Draw(texture, drawPos, rectangle, color, projectile.rotation, rectangle.Size() / 2f, projectile.scale, spriteEffects, 0f); } break; @@ -1803,8 +1640,8 @@ namespace CalamityMod.Projectiles { Color color26 = color25; color26 = projectile.GetAlpha(color26); - float num164 = (float)(whyIsThisAlwaysEight - k); - color26 *= num164 / ((float)ProjectileID.Sets.TrailCacheLength[projectile.type] * 1.5f); + float num164 = whyIsThisAlwaysEight - k; + color26 *= num164 / (ProjectileID.Sets.TrailCacheLength[projectile.type] * 1.5f); Main.spriteBatch.Draw(texture, projectile.oldPos[k] + centerOffset - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), rectangle, color26, projectile.rotation, rectangle.Size() / 2f, projectile.scale, spriteEffects, 0f); k += afterimageCounter; } @@ -1843,15 +1680,14 @@ namespace CalamityMod.Projectiles { for (int num252 = 0; num252 < 3; num252++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + Vector2 value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); while (value15.X == 0f && value15.Y == 0f) { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); } value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int newDamage = (int)(projectile.damage * 0.33); - int soul = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ProjectileID.LostSoulFriendly, newDamage, 0f, projectile.owner, 0f, 0f); + value15 *= Main.rand.Next(70, 101) * 0.1f; + int soul = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ProjectileID.LostSoulFriendly, (int)(projectile.damage * 0.33), 0f, projectile.owner, 0f, 0f); Main.projectile[soul].Calamity().forceRogue = true; Main.projectile[soul].timeLeft = 300; Main.projectile[soul].tileCollide = false; @@ -1860,25 +1696,25 @@ namespace CalamityMod.Projectiles if (modPlayer.scuttlersJewel && CalamityMod.javelinProjList.Contains(projectile.type) && Main.rand.NextBool(3)) { float dmgMult = 1f; - if (projectile.type == ModContent.ProjectileType()) + if (projectile.type == ProjectileType()) dmgMult = 0.5f; - int spike = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.5f * dmgMult), projectile.knockBack, projectile.owner); + int spike = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), (int)(projectile.damage * 0.5f * dmgMult), projectile.knockBack, projectile.owner); Main.projectile[spike].frame = 4; } } if (projectile.type == ProjectileID.UnholyWater) { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, projectile.owner, 1f); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), 0, 0f, projectile.owner, 1f); } if (projectile.type == ProjectileID.BloodWater) { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, projectile.owner, 2f); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), 0, 0f, projectile.owner, 2f); } if (projectile.type == ProjectileID.HolyWater) { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, projectile.owner, 3f); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), 0, 0f, projectile.owner, 3f); } } } @@ -1895,8 +1731,38 @@ namespace CalamityMod.Projectiles } #endregion + #region LifeSteal + public static bool CanSpawnLifeStealProjectile(Projectile projectile, float healMultiplier, float healAmount) + { + if (healMultiplier <= 0f || (int)healAmount <= 0) + return false; + + return true; + } + + public static void SpawnLifeStealProjectile(Projectile projectile, Player player, float healAmount, int healProjectileType, float distanceRequired, float cooldownMultiplier) + { + Main.player[Main.myPlayer].lifeSteal -= healAmount * cooldownMultiplier; + float num13 = 0f; + int num14 = projectile.owner; + for (int i = 0; i < Main.maxPlayers; i++) + { + if (Main.player[i].active && !Main.player[i].dead && ((!player.hostile && !Main.player[i].hostile) || player.team == Main.player[i].team)) + { + float num15 = Math.Abs(Main.player[i].position.X + (Main.player[i].width / 2) - projectile.position.X + (projectile.width / 2)) + Math.Abs(Main.player[i].position.Y + (Main.player[i].height / 2) - projectile.position.Y + (projectile.height / 2)); + if (num15 < distanceRequired && (Main.player[i].statLifeMax2 - Main.player[i].statLife) > num13) + { + num13 = Main.player[i].statLifeMax2 - Main.player[i].statLife; + num14 = i; + } + } + } + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, healProjectileType, 0, 0f, projectile.owner, num14, healAmount); + } + #endregion + #region AI Shortcuts - public void SpawnOrb(Projectile projectile, float dmgMult, int projType, float distanceRequired, float N, bool gsPhantom = false) + public void SpawnOrb(Projectile projectile, float dmgMult, int projType, float distanceRequired, float N, bool gsPhantom = false) { Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); @@ -1910,7 +1776,7 @@ namespace CalamityMod.Projectiles { if (Main.npc[i].CanBeChasedBy(projectile, false)) { - float num5 = Math.Abs(Main.npc[i].position.X + (float)(Main.npc[i].width / 2) - projectile.position.X + (float)(projectile.width / 2)) + Math.Abs(Main.npc[i].position.Y + (float)(Main.npc[i].height / 2) - projectile.position.Y + (float)(projectile.height / 2)); + float num5 = Math.Abs(Main.npc[i].position.X + (Main.npc[i].width / 2) - projectile.position.X + (projectile.width / 2)) + Math.Abs(Main.npc[i].position.Y + (Main.npc[i].height / 2) - projectile.position.Y + (projectile.height / 2)); if (num5 < distanceRequired) { if (Collision.CanHit(projectile.position, 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height) && num5 > 50f) @@ -1940,13 +1806,13 @@ namespace CalamityMod.Projectiles num6 = array[Main.rand.Next(num3)]; } float num7 = N; - float num8 = (float)Main.rand.Next(-100, 101); - float num9 = (float)Main.rand.Next(-100, 101); - float num10 = (float)Math.Sqrt((double)(num8 * num8 + num9 * num9)); + float num8 = Main.rand.Next(-100, 101); + float num9 = Main.rand.Next(-100, 101); + float num10 = (float)Math.Sqrt(num8 * num8 + num9 * num9); num10 = num7 / num10; num8 *= num10; num9 *= num10; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, num8, num9, projType, (int)(num * dmgMult), 0f, projectile.owner, gsPhantom ? 0f : (float)num6, gsPhantom ? ai1 : 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, num8, num9, projType, (int)(num * dmgMult), 0f, projectile.owner, gsPhantom ? 0f : num6, gsPhantom ? ai1 : 0f); } public static void HomeInOnNPC(Projectile projectile, bool ignoreTiles, float distanceRequired, float homingVelocity, float N) @@ -1959,7 +1825,7 @@ namespace CalamityMod.Projectiles { if (Main.npc[i].CanBeChasedBy(projectile, false)) { - float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); + float extraDistance = (Main.npc[i].width / 2) + (Main.npc[i].height / 2); bool canHit = true; if (extraDistance < maxDistance && !ignoreTiles) @@ -1995,7 +1861,7 @@ namespace CalamityMod.Projectiles { if (Main.npc[i].CanBeChasedBy(projectile, false)) { - float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); + float extraDistance = (Main.npc[i].width / 2) + (Main.npc[i].height / 2); bool canHit = true; if (extraDistance < maxDistance) @@ -2027,7 +1893,7 @@ namespace CalamityMod.Projectiles Vector2 value = projectile.Center + projectile.velocity * 4f; Vector2 velocity = Vector2.Normalize(Main.npc[randomTarget].Center - value) * homingVelocity; - if (projectile.type == ModContent.ProjectileType()) + if (projectile.type == ProjectileType()) { velocity.Y += Main.rand.Next(-30, 31) * 0.05f; velocity.X += Main.rand.Next(-30, 31) * 0.05f; @@ -2037,28 +1903,74 @@ namespace CalamityMod.Projectiles { int projectile2 = Projectile.NewProjectile(value.X, value.Y, velocity.X, velocity.Y, spawnedProjectile, (int)(projectile.damage * damageMult), projectile.knockBack, projectile.owner, 0f, 0f); - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || (projectile.type == ModContent.ProjectileType() && projectile.melee)) + if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || + projectile.type == ProjectileType() || projectile.type == ProjectileType() || (projectile.type == ProjectileType() && projectile.melee)) Main.projectile[projectile2].Calamity().forceMelee = true; - if (projectile.type == ModContent.ProjectileType() && projectile.Calamity().rogue) + if (projectile.type == ProjectileType() && projectile.Calamity().rogue) Main.projectile[projectile2].Calamity().forceRogue = true; } } } } + public static void HealingProjectile(Projectile projectile, int healing, int playerToHeal, float homingVelocity, float N, bool autoHomes = true, int timeCheck = 120) + { + int target = playerToHeal; + Player player = Main.player[target]; + float homingSpeed = homingVelocity; + if (player.lifeMagnet) + homingSpeed *= 1.5f; + + Vector2 projPos = new Vector2(projectile.Center.X, projectile.Center.Y); + float xDist = player.Center.X - projPos.X; + float yDist = player.Center.Y - projPos.Y; + Vector2 playerVector = new Vector2(xDist, yDist); + float playerDist = playerVector.Length(); + if (playerDist < 50f && projectile.position.X < player.position.X + player.width && projectile.position.X + projectile.width > player.position.X && projectile.position.Y < player.position.Y + player.height && projectile.position.Y + projectile.height > player.position.Y) + { + if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) + { + int healAmt = healing; + player.HealEffect(healAmt, false); + player.statLife += healAmt; + if (player.statLife > player.statLifeMax2) + { + player.statLife = player.statLifeMax2; + } + NetMessage.SendData(66, -1, -1, null, target, healAmt, 0f, 0f, 0, 0, 0); + } + projectile.Kill(); + } + if (autoHomes) + { + playerDist = homingSpeed / playerDist; + playerVector.X *= playerDist; + playerVector.Y *= playerDist; + projectile.velocity.X = (projectile.velocity.X * N + playerVector.X) / (N + 1f); + projectile.velocity.Y = (projectile.velocity.Y * N + playerVector.Y) / (N + 1f); + } + else if (player.lifeMagnet && projectile.timeLeft < timeCheck) + { + playerDist = homingVelocity / playerDist; + playerVector.X *= playerDist; + playerVector.Y *= playerDist; + projectile.velocity.X = (projectile.velocity.X * N + playerVector.X) / (N + 1f); + projectile.velocity.Y = (projectile.velocity.Y * N + playerVector.Y) / (N + 1f); + } + } + public static void FloatingPetAI(Projectile projectile, bool faceRight, float tiltFloat, bool lightPet = false) { Player player = Main.player[projectile.owner]; - //anti sticking movement as a backup + //anti sticking movement as a failsafe float SAImovement = 0.05f; for (int index = 0; index < Main.projectile.Length; index++) { Projectile proj = Main.projectile[index]; bool flag23 = Main.projPet[proj.type]; - if (index != projectile.whoAmI && proj.active && proj.owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < (float)projectile.width) + if (index != projectile.whoAmI && proj.active && proj.owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) { if (projectile.position.X < proj.position.X) { @@ -2079,23 +1991,24 @@ namespace CalamityMod.Projectiles } } - float num16 = 0.5f; + float passiveMvtFloat = 0.5f; projectile.tileCollide = false; float range = 100f; - Vector2 vector3 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float xDist = player.position.X + (float)(player.width / 2) - vector3.X; - float yDist = player.position.Y + (float)(player.height / 2) - vector3.Y; - yDist += (float)Main.rand.Next(-10, 21); - xDist += (float)Main.rand.Next(-10, 21); - //light pets lead the player, normal pets trail the player - xDist += (float)(60 * (lightPet ? (float)player.direction : -(float)player.direction)); + Vector2 projPos = new Vector2(projectile.Center.X, projectile.Center.Y); + float xDist = player.Center.X - projPos.X; + float yDist = player.Center.Y - projPos.Y; + yDist += Main.rand.NextFloat(-10, 20); + xDist += Main.rand.NextFloat(-10, 20); + //Light pets lead the player, normal pets trail the player + xDist += 60f * (lightPet ? (float)player.direction : -(float)player.direction); yDist -= 60f; - float playerDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); - float num21 = 18f; + Vector2 playerVector = new Vector2(xDist, yDist); + float playerDist = playerVector.Length(); + float returnSpeed = 18f; - //if player is close enough, resume normal + //If player is close enough, resume normal if (playerDist < range && player.velocity.Y == 0f && - projectile.position.Y + (float)projectile.height <= player.position.Y + (float)player.height && + projectile.position.Y + projectile.height <= player.position.Y + player.height && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) { if (projectile.velocity.Y < -6f) @@ -2104,11 +2017,11 @@ namespace CalamityMod.Projectiles } } - //teleport to player if too far + //Teleport to player if too far if (playerDist > 2000f) { - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); + projectile.position.X = player.Center.X - projectile.width / 2; + projectile.position.Y = player.Center.Y - projectile.height / 2; projectile.netUpdate = true; } @@ -2118,52 +2031,52 @@ namespace CalamityMod.Projectiles { projectile.velocity *= 0.99f; } - num16 = 0.01f; + passiveMvtFloat = 0.01f; } else { if (playerDist < 100f) { - num16 = 0.1f; + passiveMvtFloat = 0.1f; } if (playerDist > 300f) { - num16 = 1f; + passiveMvtFloat = 1f; } - playerDist = num21 / playerDist; - xDist *= playerDist; - yDist *= playerDist; + playerDist = returnSpeed / playerDist; + playerVector.X *= playerDist; + playerVector.Y *= playerDist; } - if (projectile.velocity.X < xDist) + if (projectile.velocity.X < playerVector.X) { - projectile.velocity.X = projectile.velocity.X + num16; - if (num16 > 0.05f && projectile.velocity.X < 0f) + projectile.velocity.X += passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.X < 0f) { - projectile.velocity.X = projectile.velocity.X + num16; + projectile.velocity.X += passiveMvtFloat; } } - if (projectile.velocity.X > xDist) + if (projectile.velocity.X > playerVector.X) { - projectile.velocity.X = projectile.velocity.X - num16; - if (num16 > 0.05f && projectile.velocity.X > 0f) + projectile.velocity.X -= passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.X > 0f) { - projectile.velocity.X = projectile.velocity.X - num16; + projectile.velocity.X -= passiveMvtFloat; } } - if (projectile.velocity.Y < yDist) + if (projectile.velocity.Y < playerVector.Y) { - projectile.velocity.Y = projectile.velocity.Y + num16; - if (num16 > 0.05f && projectile.velocity.Y < 0f) + projectile.velocity.Y += passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.Y < 0f) { - projectile.velocity.Y = projectile.velocity.Y + num16 * 2f; + projectile.velocity.Y += passiveMvtFloat * 2f; } } - if (projectile.velocity.Y > yDist) + if (projectile.velocity.Y > playerVector.Y) { - projectile.velocity.Y = projectile.velocity.Y - num16; - if (num16 > 0.05f && projectile.velocity.Y > 0f) + projectile.velocity.Y -= passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.Y > 0f) { - projectile.velocity.Y = projectile.velocity.Y - num16 * 2f; + projectile.velocity.Y -= passiveMvtFloat * 2f; } } if (projectile.velocity.X >= 0.25f) diff --git a/Projectiles/Damageable/ArtifactOfResilienceBulwark.cs b/Projectiles/Damageable/ArtifactOfResilienceBulwark.cs index 341ecdcff2..dcf0fe3527 100644 --- a/Projectiles/Damageable/ArtifactOfResilienceBulwark.cs +++ b/Projectiles/Damageable/ArtifactOfResilienceBulwark.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Projectiles.Damageable { public int Reformations = 0; public const int MaxReformations = 3; - public override int LifeMax => 30000; + public override int LifeMax => 1; public override int MaxDamageImmunityFrames => 5; public override DamageSourceType DamageSources => DamageSourceType.FriendlyProjectiles | DamageSourceType.HostileProjectiles | DamageSourceType.HostileNPCs; public override LegacySoundStyle HitSound => SoundID.NPCHit3; @@ -38,10 +38,6 @@ namespace CalamityMod.Projectiles.Damageable dust.noGravity = true; } } - public override void HitEffectProjectile(int damage, Projectile target) - { - target.Kill(); - } public override void DamageKillEffect() { Utils.PoofOfSmoke(projectile.Center); diff --git a/Projectiles/DraedonsArsenal/GatlingLaserProj.cs b/Projectiles/DraedonsArsenal/GatlingLaserProj.cs index e75f7c98c1..dc73b8464b 100644 --- a/Projectiles/DraedonsArsenal/GatlingLaserProj.cs +++ b/Projectiles/DraedonsArsenal/GatlingLaserProj.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal int fireRate = 2; projectile.ai[1] += 1f; bool flag = false; - if (projectile.ai[1] >= (float)fireRate) + if (projectile.ai[1] >= fireRate) { projectile.ai[1] = 0f; flag = true; @@ -61,19 +61,19 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } if (flag && Main.myPlayer == projectile.owner && fireLasers) { - int weaponDamage2 = player.GetWeaponDamage(player.inventory[player.selectedItem]); + int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); bool flag2 = player.channel && !player.noItems && !player.CCed; if (flag2) { // Consume 2 ammo per shot - CalamityGlobalItem.ConsumeAdditionalAmmo(player, player.inventory[player.selectedItem], 2); + CalamityGlobalItem.ConsumeAdditionalAmmo(player, player.ActiveItem(), 2); - float scaleFactor = player.inventory[player.selectedItem].shootSpeed * projectile.scale; + float scaleFactor = player.ActiveItem().shootSpeed * projectile.scale; Vector2 value2 = vector; - Vector2 value3 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - value2; + Vector2 value3 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - value2; if (player.gravDir == -1f) { - value3.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - value2.Y; + value3.Y = Main.screenHeight - Main.mouseY + Main.screenPosition.Y - value2.Y; } Vector2 vector3 = Vector2.Normalize(value3); if (float.IsNaN(vector3.X) || float.IsNaN(vector3.Y)) @@ -90,7 +90,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal float velocity = 3f; value2 = projectile.Center; Vector2 spinningpoint = Vector2.Normalize(projectile.velocity) * velocity; - spinningpoint = spinningpoint.RotatedBy(Main.rand.NextDouble() * 0.19634954631328583 - 0.098174773156642914, default(Vector2)); + spinningpoint = spinningpoint.RotatedBy(Main.rand.NextDouble() * 0.19634954631328583 - 0.098174773156642914); if (float.IsNaN(spinningpoint.X) || float.IsNaN(spinningpoint.Y)) { spinningpoint = -Vector2.UnitY; @@ -101,15 +101,18 @@ namespace CalamityMod.Projectiles.DraedonsArsenal velocity2.Normalize(); velocity2 *= 5f; } - float SpeedX = velocity2.X + (float)Main.rand.Next(-1, 2) * 0.01f; - float SpeedY = velocity2.Y + (float)Main.rand.Next(-1, 2) * 0.01f; + float SpeedX = velocity2.X + Main.rand.Next(-1, 2) * 0.01f; + float SpeedY = velocity2.Y + Main.rand.Next(-1, 2) * 0.01f; float ai0 = projectile.ai[0] - 2f; // 0, 1, or 2 Projectile.NewProjectile(value2.X, value2.Y, SpeedX, SpeedY, type, weaponDamage2, projectile.knockBack, projectile.owner, ai0, 0f); } else { - gatlingLaserLoop.Stop(); + if (gatlingLaserLoop != null) + gatlingLaserLoop.Stop(); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/GatlingLaserFireEnd"), (int)projectile.position.X, (int)projectile.position.Y); + projectile.Kill(); } } @@ -122,7 +125,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal player.heldProj = projectile.whoAmI; player.itemTime = 2; player.itemAnimation = 2; - player.itemRotation = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction)); + player.itemRotation = (float)Math.Atan2(projectile.velocity.Y * projectile.direction, projectile.velocity.X * projectile.direction); } } } diff --git a/Projectiles/Environment/LightningMark.cs b/Projectiles/Environment/LightningMark.cs index c1e4a22a78..b3971032e5 100644 --- a/Projectiles/Environment/LightningMark.cs +++ b/Projectiles/Environment/LightningMark.cs @@ -85,6 +85,12 @@ namespace CalamityMod.Projectiles.Environment projectile.velocity.Y = 16f; } + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough) + { + fallThrough = false; + return true; + } + public override bool OnTileCollide(Vector2 oldVelocity) { return false; diff --git a/Projectiles/Healing/AtaxiaHealOrb.cs b/Projectiles/Healing/AtaxiaHealOrb.cs index cd2312f5d7..98aa375101 100644 --- a/Projectiles/Healing/AtaxiaHealOrb.cs +++ b/Projectiles/Healing/AtaxiaHealOrb.cs @@ -24,43 +24,12 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - int num487 = (int)projectile.ai[0]; - float num488 = 5.5f; - if (Main.player[num487].lifeMagnet) - num488 *= 1.5f; - - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = (int)projectile.ai[1]; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f; - float num498 = projectile.velocity.X * 0.2f; - float num499 = -(projectile.velocity.Y * 0.2f); - int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 127, 0f, 0f, 100, default, 2f); - Main.dust[num500].noGravity = true; - Dust expr_154F9_cp_0 = Main.dust[num500]; - expr_154F9_cp_0.position.X -= num498; - Dust expr_15518_cp_0 = Main.dust[num500]; - expr_15518_cp_0.position.Y -= num499; + CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f); + int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 127, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[dusty]; + dust.noGravity = true; + dust.position.X -= projectile.velocity.X * 0.2f; + dust.position.Y += projectile.velocity.Y * 0.2f; } } } diff --git a/Projectiles/Healing/AuricOrb.cs b/Projectiles/Healing/AuricOrb.cs index 7fa77e8d85..74adb60d7d 100644 --- a/Projectiles/Healing/AuricOrb.cs +++ b/Projectiles/Healing/AuricOrb.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Healing if (projectile.localAI[0] == 0f) { projectile.scale += 0.05f; - if ((double)projectile.scale > 1.2) + if (projectile.scale > 1.2f) { projectile.localAI[0] = 1f; } @@ -36,41 +36,13 @@ namespace CalamityMod.Projectiles.Healing else { projectile.scale -= 0.05f; - if ((double)projectile.scale < 0.8) + if (projectile.scale < 0.8f) { projectile.localAI[0] = 0f; } } - int num487 = (int)projectile.ai[0]; - float num488 = 6f; - if (Main.player[num487].lifeMagnet) - num488 *= 1.5f; - - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = (int)projectile.ai[1]; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f; + CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 6f, 15f); return; } diff --git a/Projectiles/Healing/BurntSiennaProj.cs b/Projectiles/Healing/BurntSiennaProj.cs index 6c379fd841..6c2ed80366 100644 --- a/Projectiles/Healing/BurntSiennaProj.cs +++ b/Projectiles/Healing/BurntSiennaProj.cs @@ -27,42 +27,12 @@ namespace CalamityMod.Projectiles.Healing projectile.velocity.X *= 0.95f; projectile.velocity.Y *= 0.95f; - int num487 = (int)projectile.ai[0]; - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = 3; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - if (Main.player[num487].lifeMagnet && projectile.timeLeft < 120) - { - float num488 = 6f; - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f; - } - float num498 = projectile.velocity.X * 0.2f; - float num499 = -(projectile.velocity.Y * 0.2f); - int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 246, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[num500]; + CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 6f, 15f, false); + int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 246, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[dusty]; dust.noGravity = true; - dust.position.X -= num498; - dust.position.Y -= num499; + dust.position.X -= projectile.velocity.X * 0.2f; + dust.position.Y += projectile.velocity.Y * 0.2f; } } } diff --git a/Projectiles/Healing/CactusHealOrb.cs b/Projectiles/Healing/CactusHealOrb.cs index 03a13de375..4d919c5b6a 100644 --- a/Projectiles/Healing/CactusHealOrb.cs +++ b/Projectiles/Healing/CactusHealOrb.cs @@ -26,42 +26,12 @@ namespace CalamityMod.Projectiles.Healing { projectile.velocity.Y *= 0.98f; - int num487 = projectile.owner; - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = 25; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - if (Main.player[num487].lifeMagnet && projectile.timeLeft < 120) - { - float num488 = 12f; - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f; - } - float num498 = projectile.velocity.X * 0.2f; - float num499 = -(projectile.velocity.Y * 0.2f); - int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(0, 200, 0), 1.5f); - Dust dust = Main.dust[num500]; - dust.noGravity = true; - dust.position.X -= num498; - dust.position.Y -= num499; + CalamityGlobalProjectile.HealingProjectile(projectile, 25, projectile.owner, 12f, 15f); + int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(0, 200, 0), 1.5f); + Dust dust = Main.dust[dusty]; + dust.noGravity = true; + dust.position.X -= projectile.velocity.X * 0.2f; + dust.position.Y += projectile.velocity.Y * 0.2f; } } } diff --git a/Projectiles/Healing/EarthHealOrb.cs b/Projectiles/Healing/EarthHealOrb.cs index cf5182f33f..1b0f469446 100644 --- a/Projectiles/Healing/EarthHealOrb.cs +++ b/Projectiles/Healing/EarthHealOrb.cs @@ -24,42 +24,12 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - int num487 = (int)projectile.ai[0]; - float num488 = 8f; - if (Main.player[num487].lifeMagnet) - num488 *= 1.5f; - - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = (int)projectile.ai[1]; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f; - float num498 = projectile.velocity.X * 0.2f; - float num499 = -(projectile.velocity.Y * 0.2f); - int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 74, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[num500]; + CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 8f, 15f); + int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 74, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[dusty]; dust.noGravity = true; - dust.position.X -= num498; - dust.position.Y -= num499; + dust.position.X -= projectile.velocity.X * 0.2f; + dust.position.Y += projectile.velocity.Y * 0.2f; } } } diff --git a/Projectiles/Healing/EssenceFlame.cs b/Projectiles/Healing/EssenceFlame.cs index 24f49646a4..4b628fbf2a 100644 --- a/Projectiles/Healing/EssenceFlame.cs +++ b/Projectiles/Healing/EssenceFlame.cs @@ -38,35 +38,7 @@ namespace CalamityMod.Projectiles.Healing projectile.frame = 0; } - int num487 = (int)projectile.ai[0]; - float num488 = 3.5f; - if (Main.player[num487].lifeMagnet) - num488 *= 1.5f; - - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = 8; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f; + CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 3.5f, 15f); return; } diff --git a/Projectiles/Healing/Exoheal.cs b/Projectiles/Healing/Exoheal.cs index 9709142587..f2e6e2b59d 100644 --- a/Projectiles/Healing/Exoheal.cs +++ b/Projectiles/Healing/Exoheal.cs @@ -24,42 +24,12 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - int num487 = (int)projectile.ai[0]; - float num488 = 8f; - if (Main.player[num487].lifeMagnet) - num488 *= 1.5f; - - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = (int)projectile.ai[1]; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f; - float num498 = projectile.velocity.X * 0.2f; - float num499 = -(projectile.velocity.Y * 0.2f); - int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); - Dust dust = Main.dust[num500]; + CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 8f, 15f); + int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + Dust dust = Main.dust[dusty]; dust.noGravity = true; - dust.position.X -= num498; - dust.position.Y -= num499; + dust.position.X -= projectile.velocity.X * 0.2f; + dust.position.Y += projectile.velocity.Y * 0.2f; } } } diff --git a/Projectiles/Healing/FungalHeal.cs b/Projectiles/Healing/FungalHeal.cs index 8921a2bbc1..8b064add99 100644 --- a/Projectiles/Healing/FungalHeal.cs +++ b/Projectiles/Healing/FungalHeal.cs @@ -26,49 +26,21 @@ namespace CalamityMod.Projectiles.Healing if (projectile.localAI[0] == 0f) { Player player = Main.player[projectile.owner]; - if ((player.inventory[player.selectedItem].summon && - !player.inventory[player.selectedItem].melee && - !player.inventory[player.selectedItem].ranged && - !player.inventory[player.selectedItem].magic && - !player.inventory[player.selectedItem].Calamity().rogue) || - player.inventory[player.selectedItem].hammer > 0 || - player.inventory[player.selectedItem].pick > 0 || - player.inventory[player.selectedItem].axe > 0) + if ((player.ActiveItem().summon && + !player.ActiveItem().melee && + !player.ActiveItem().ranged && + !player.ActiveItem().magic && + !player.ActiveItem().Calamity().rogue) || + player.ActiveItem().hammer > 0 || + player.ActiveItem().pick > 0 || + player.ActiveItem().axe > 0) { projectile.timeLeft = 600; } projectile.localAI[0] += 1f; } - int num487 = (int)projectile.ai[0]; - float num488 = 5f; - if (Main.player[num487].lifeMagnet) - num488 *= 1.5f; - - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = (int)projectile.ai[1]; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 9f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 9f + num490) / 16f; + CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 5f, 15f); float num494 = projectile.velocity.X * 0.334f; float num495 = -(projectile.velocity.Y * 0.334f); int num496 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 56, 0f, 0f, 100, default, 0.5f); diff --git a/Projectiles/Healing/GodSlayerHealOrb.cs b/Projectiles/Healing/GodSlayerHealOrb.cs index aa21e884f8..76ab25d25d 100644 --- a/Projectiles/Healing/GodSlayerHealOrb.cs +++ b/Projectiles/Healing/GodSlayerHealOrb.cs @@ -24,42 +24,12 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - int num487 = (int)projectile.ai[0]; - float num488 = 6.5f; - if (Main.player[num487].lifeMagnet) - num488 *= 1.5f; - - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = (int)projectile.ai[1]; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f; - float num498 = projectile.velocity.X * 0.2f; - float num499 = -(projectile.velocity.Y * 0.2f); - int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 173, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[num500]; + CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 6.5f, 15f); + int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 173, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[dusty]; dust.noGravity = true; - dust.position.X -= num498; - dust.position.Y -= num499; + dust.position.X -= projectile.velocity.X * 0.2f; + dust.position.Y += projectile.velocity.Y * 0.2f; } } } diff --git a/Projectiles/Healing/ManaOverloaderHealOrb.cs b/Projectiles/Healing/ManaOverloaderHealOrb.cs new file mode 100644 index 0000000000..4a6a1773a8 --- /dev/null +++ b/Projectiles/Healing/ManaOverloaderHealOrb.cs @@ -0,0 +1,35 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Healing +{ + public class ManaOverloaderHealOrb : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Mana Overloader Heal Orb"); + } + + public override void SetDefaults() + { + projectile.width = 4; + projectile.height = 4; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.timeLeft = 180; + projectile.extraUpdates = 3; + } + + public override void AI() + { + CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 3f, 15f); + int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 175, 0f, 0f, 100, default, 1.3f); + Dust dust = Main.dust[dusty]; + dust.noGravity = true; + dust.position.X -= projectile.velocity.X * 0.2f; + dust.position.Y += projectile.velocity.Y * 0.2f; + } + } +} diff --git a/Projectiles/Healing/ManaOverloaderHealOrb.png b/Projectiles/Healing/ManaOverloaderHealOrb.png new file mode 100644 index 0000000000..15e8775737 Binary files /dev/null and b/Projectiles/Healing/ManaOverloaderHealOrb.png differ diff --git a/Projectiles/Healing/PhoenixHeal.cs b/Projectiles/Healing/PhoenixHeal.cs index 2c36dc2da9..d876795420 100644 --- a/Projectiles/Healing/PhoenixHeal.cs +++ b/Projectiles/Healing/PhoenixHeal.cs @@ -25,35 +25,7 @@ namespace CalamityMod.Projectiles.Healing { projectile.velocity.X *= 0.95f; projectile.velocity.Y *= 0.95f; - int num487 = (int)projectile.ai[0]; - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = 10; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - if (Main.player[num487].lifeMagnet && projectile.timeLeft < 360) - { - float num488 = 6f; - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f; - } + CalamityGlobalProjectile.HealingProjectile(projectile, 10, (int)projectile.ai[0], 6f, 15f, false, 360); float num498 = projectile.velocity.X * 0.2f; float num499 = -(projectile.velocity.Y * 0.2f); int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); diff --git a/Projectiles/Healing/RainHeal.cs b/Projectiles/Healing/RainHeal.cs index 35fb70becc..492030d13b 100644 --- a/Projectiles/Healing/RainHeal.cs +++ b/Projectiles/Healing/RainHeal.cs @@ -26,35 +26,8 @@ namespace CalamityMod.Projectiles.Healing { projectile.velocity.X *= 0.985f; projectile.velocity.Y *= 0.985f; - int num487 = projectile.owner; - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = 8; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - if (Main.player[num487].lifeMagnet && projectile.timeLeft < 120) - { - float num488 = 12f; - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f; - } + CalamityGlobalProjectile.HealingProjectile(projectile, 8, projectile.owner, 12f, 15f, false); + float num498 = projectile.velocity.X * 0.2f; float num499 = -(projectile.velocity.Y * 0.2f); int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); diff --git a/Projectiles/Healing/RoyalHeal.cs b/Projectiles/Healing/RoyalHeal.cs index 5872a3d6f5..a5f7a0fea3 100644 --- a/Projectiles/Healing/RoyalHeal.cs +++ b/Projectiles/Healing/RoyalHeal.cs @@ -22,35 +22,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - int num487 = (int)projectile.ai[0]; - float num488 = 5.5f; - if (Main.player[num487].lifeMagnet) - num488 *= 1.5f; - - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = (int)projectile.ai[1]; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f; + CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f); for (int num493 = 0; num493 < 3; num493++) { float num494 = projectile.velocity.X * 0.334f * (float)num493; diff --git a/Projectiles/Healing/ShinobiHealOrb.cs b/Projectiles/Healing/ShinobiHealOrb.cs index d79d4fba0d..0361dfd5df 100644 --- a/Projectiles/Healing/ShinobiHealOrb.cs +++ b/Projectiles/Healing/ShinobiHealOrb.cs @@ -26,36 +26,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - int num487 = projectile.owner; - - float num488 = 6f; - if (Main.player[num487].lifeMagnet) - num488 *= 1.5f; - - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = (int)projectile.ai[1]; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f; + CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], projectile.owner, 6f, 15f); for (int num468 = 0; num468 < 3; num468++) { diff --git a/Projectiles/Healing/SilvaOrb.cs b/Projectiles/Healing/SilvaOrb.cs index 30b293bc9f..4da5cec31c 100644 --- a/Projectiles/Healing/SilvaOrb.cs +++ b/Projectiles/Healing/SilvaOrb.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Healing if (projectile.localAI[0] == 0f) { projectile.scale += 0.05f; - if ((double)projectile.scale > 1.2) + if (projectile.scale > 1.2f) { projectile.localAI[0] = 1f; } @@ -36,41 +36,13 @@ namespace CalamityMod.Projectiles.Healing else { projectile.scale -= 0.05f; - if ((double)projectile.scale < 0.8) + if (projectile.scale < 0.8f) { projectile.localAI[0] = 0f; } } - int num487 = (int)projectile.ai[0]; - float num488 = 6f; - if (Main.player[num487].lifeMagnet) - num488 *= 1.5f; - - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = (int)projectile.ai[1]; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f; + CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 6f, 15f); return; } diff --git a/Projectiles/Healing/TerracottaProj.cs b/Projectiles/Healing/TerracottaProj.cs index bae4b5b362..14ae4bc480 100644 --- a/Projectiles/Healing/TerracottaProj.cs +++ b/Projectiles/Healing/TerracottaProj.cs @@ -27,35 +27,7 @@ namespace CalamityMod.Projectiles.Healing projectile.velocity.X *= 0.95f; projectile.velocity.Y *= 0.95f; - int num487 = (int)projectile.ai[0]; - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = 9; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - if (Main.player[num487].lifeMagnet && projectile.timeLeft < 300) - { - float num488 = 8f; - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f; - } + CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 8f, 15f, false, 300); float num498 = projectile.velocity.X * 0.2f; float num499 = -(projectile.velocity.Y * 0.2f); int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 246, 0f, 0f, 100, default, 1f); diff --git a/Projectiles/Healing/TransfusionTrail.cs b/Projectiles/Healing/TransfusionTrail.cs index b8f10e80a9..741959f1e7 100644 --- a/Projectiles/Healing/TransfusionTrail.cs +++ b/Projectiles/Healing/TransfusionTrail.cs @@ -22,35 +22,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - int num487 = (int)projectile.ai[0]; - float num488 = 6.5f; - if (Main.player[num487].lifeMagnet) - num488 *= 1.5f; - - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = (int)projectile.ai[1]; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 9f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 9f + num490) / 16f; + CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 6.5f, 15f); float num494 = projectile.velocity.X * 0.334f; float num495 = -(projectile.velocity.Y * 0.334f); int num496 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 183, 0f, 0f, 100, default, 0.7f); diff --git a/Projectiles/Healing/XerocHealOrb.cs b/Projectiles/Healing/XerocHealOrb.cs index cd41a696c3..5ab79c1a15 100644 --- a/Projectiles/Healing/XerocHealOrb.cs +++ b/Projectiles/Healing/XerocHealOrb.cs @@ -24,35 +24,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - int num487 = (int)projectile.ai[0]; - float num488 = 5.5f; - if (Main.player[num487].lifeMagnet) - num488 *= 1.5f; - - Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num489 = Main.player[num487].Center.X - vector36.X; - float num490 = Main.player[num487].Center.Y - vector36.Y; - float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490)); - if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int num492 = (int)projectile.ai[1]; - Main.player[num487].HealEffect(num492, false); - Main.player[num487].statLife += num492; - if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) - { - Main.player[num487].statLife = Main.player[num487].statLifeMax2; - } - NetMessage.SendData(66, -1, -1, null, num487, (float)num492, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - num491 = num488 / num491; - num489 *= num491; - num490 *= num491; - projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f; - projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f; + CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f); float num498 = projectile.velocity.X * 0.2f; float num499 = -(projectile.velocity.Y * 0.2f); int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 58, 0f, 0f, 100, default, 2f); diff --git a/Projectiles/Hybrid/CorpusAvertorClone.cs b/Projectiles/Hybrid/CorpusAvertorClone.cs index 1bd9edd5c9..1210f3270e 100644 --- a/Projectiles/Hybrid/CorpusAvertorClone.cs +++ b/Projectiles/Hybrid/CorpusAvertorClone.cs @@ -85,9 +85,7 @@ namespace CalamityMod.Projectiles.Hybrid if (Main.player[Main.myPlayer].lifeSteal <= 0f) return; - Main.player[Main.myPlayer].lifeSteal -= heal * 1.5f; - int owner = projectile.owner; - Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, ProjectileID.VampireHeal, 0, 0f, projectile.owner, (float)owner, heal); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], heal, ProjectileID.VampireHeal, 1200f, 1.5f); } public override void OnHitPvp(Player target, int damage, bool crit) @@ -98,9 +96,7 @@ namespace CalamityMod.Projectiles.Hybrid if (Main.player[Main.myPlayer].lifeSteal <= 0f) return; - Main.player[Main.myPlayer].lifeSteal -= heal * 1.5f; - int owner = projectile.owner; - Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, ProjectileID.VampireHeal, 0, 0f, projectile.owner, (float)owner, heal); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], heal, ProjectileID.VampireHeal, 1200f, 1.5f); } } } diff --git a/Projectiles/Hybrid/CorpusAvertorProj.cs b/Projectiles/Hybrid/CorpusAvertorProj.cs index 0d6d1935cb..4e41dfb165 100644 --- a/Projectiles/Hybrid/CorpusAvertorProj.cs +++ b/Projectiles/Hybrid/CorpusAvertorProj.cs @@ -90,9 +90,7 @@ namespace CalamityMod.Projectiles.Hybrid if (Main.player[Main.myPlayer].lifeSteal <= 0f) return; - Main.player[Main.myPlayer].lifeSteal -= heal * 1.5f; - int owner = projectile.owner; - Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, ProjectileID.VampireHeal, 0, 0f, projectile.owner, (float)owner, heal); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], heal, ProjectileID.VampireHeal, 1200f, 1.5f); } public override void OnHitPvp(Player target, int damage, bool crit) @@ -103,9 +101,7 @@ namespace CalamityMod.Projectiles.Hybrid if (Main.player[Main.myPlayer].lifeSteal <= 0f) return; - Main.player[Main.myPlayer].lifeSteal -= heal * 1.5f; - int owner = projectile.owner; - Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, ProjectileID.VampireHeal, 0, 0f, projectile.owner, (float)owner, heal); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], heal, ProjectileID.VampireHeal, 1200f, 1.5f); } } } diff --git a/Projectiles/Hybrid/EmpyreanKnife.cs b/Projectiles/Hybrid/EmpyreanKnife.cs index 0ccd843fb8..17908efb24 100644 --- a/Projectiles/Hybrid/EmpyreanKnife.cs +++ b/Projectiles/Hybrid/EmpyreanKnife.cs @@ -40,8 +40,8 @@ namespace CalamityMod.Projectiles.Hybrid if (projectile.ai[0] >= 75f) { projectile.alpha += 10; - projectile.damage = (int)((double)projectile.damage * 0.95); - projectile.knockBack = (float)(int)((double)projectile.knockBack * 0.95); + projectile.damage = (int)(projectile.damage * 0.95); + projectile.knockBack = projectile.knockBack * 0.95f; if (projectile.alpha >= 255) { projectile.active = false; @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Hybrid } if (projectile.ai[0] < 75f) { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; } else { @@ -100,8 +100,8 @@ namespace CalamityMod.Projectiles.Hybrid { return; } - float num = (float)damage * 0.005f; - if ((int)num == 0) + float healAmt = (float)damage * 0.005f; + if ((int)healAmt == 0) { return; } @@ -109,15 +109,13 @@ namespace CalamityMod.Projectiles.Hybrid { return; } - Main.player[Main.myPlayer].lifeSteal -= num * 1.5f; - int num2 = projectile.owner; - Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, 305, 0, 0f, projectile.owner, (float)num2, num); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ProjectileID.VampireHeal, 1200f, 1.5f); } public override void OnHitPvp(Player target, int damage, bool crit) { - float num = (float)damage * 0.005f; - if ((int)num == 0) + float healAmt = (float)damage * 0.005f; + if ((int)healAmt == 0) { return; } @@ -125,9 +123,7 @@ namespace CalamityMod.Projectiles.Hybrid { return; } - Main.player[Main.myPlayer].lifeSteal -= num * 1.5f; - int num2 = projectile.owner; - Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, 305, 0, 0f, projectile.owner, (float)num2, num); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ProjectileID.VampireHeal, 1200f, 1.5f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/IllustriousKnife.cs b/Projectiles/Hybrid/IllustriousKnife.cs similarity index 81% rename from Projectiles/Rogue/IllustriousKnife.cs rename to Projectiles/Hybrid/IllustriousKnife.cs index 4d27eeea5e..843ec6fe90 100644 --- a/Projectiles/Rogue/IllustriousKnife.cs +++ b/Projectiles/Hybrid/IllustriousKnife.cs @@ -6,7 +6,7 @@ using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Rogue +namespace CalamityMod.Projectiles.Hybrid { public class IllustriousKnife : ModProjectile { @@ -69,8 +69,8 @@ namespace CalamityMod.Projectiles.Rogue { return; } - float num = (float)damage * 0.015f; - if ((int)num == 0) + float healAmt = (float)damage * 0.015f; + if ((int)healAmt == 0) { return; } @@ -78,16 +78,14 @@ namespace CalamityMod.Projectiles.Rogue { return; } - Main.player[Main.myPlayer].lifeSteal -= num * 1.5f; - int num2 = projectile.owner; - Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, projectile.owner, (float)num2, num); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 1.5f); } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 600); - float num = (float)damage * 0.015f; - if ((int)num == 0) + float healAmt = (float)damage * 0.015f; + if ((int)healAmt == 0) { return; } @@ -95,9 +93,7 @@ namespace CalamityMod.Projectiles.Rogue { return; } - Main.player[Main.myPlayer].lifeSteal -= num * 1.5f; - int num2 = projectile.owner; - Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, projectile.owner, (float)num2, num); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 1.5f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/IllustriousKnife.png b/Projectiles/Hybrid/IllustriousKnife.png similarity index 100% rename from Projectiles/Rogue/IllustriousKnife.png rename to Projectiles/Hybrid/IllustriousKnife.png diff --git a/Projectiles/Magic/Ancient.cs b/Projectiles/Magic/Ancient.cs index e4b374321d..85686900da 100644 --- a/Projectiles/Magic/Ancient.cs +++ b/Projectiles/Magic/Ancient.cs @@ -5,8 +5,6 @@ namespace CalamityMod.Projectiles.Magic { public class Ancient : ModProjectile { - public int addDustTimer = 0; - public override void SetStaticDefaults() { DisplayName.SetDefault("Ancient"); @@ -30,8 +28,7 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { Lighting.AddLight(projectile.Center, 0.6f, 0.5f, 0f); - addDustTimer++; - if (addDustTimer >= 30) + if (projectile.timeLeft % 30 == 0) { int numProj = 2; int randomSpread = Main.rand.Next(3, 19); @@ -41,10 +38,9 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < numProj + 1; i++) { Vector2 perturbedSpeed = new Vector2(projectile.velocity.X, projectile.velocity.Y).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, 0f, 0f); } } - addDustTimer = 0; } if (projectile.timeLeft > 151) { @@ -70,46 +66,40 @@ namespace CalamityMod.Projectiles.Magic for (int num298 = 0; num298 < 2; num298++) { int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[num299]; if (Main.rand.NextBool(2)) { - Main.dust[num299].noGravity = true; - Main.dust[num299].scale *= 2f; - Dust expr_DBEF_cp_0 = Main.dust[num299]; - expr_DBEF_cp_0.velocity.X *= 6f; - Dust expr_DC0F_cp_0 = Main.dust[num299]; - expr_DC0F_cp_0.velocity.Y *= 6f; + dust.noGravity = true; + dust.scale *= 2f; + dust.velocity.X *= 6f; + dust.velocity.Y *= 6f; } else { - Main.dust[num299].scale *= 1.5f; + dust.scale *= 1.5f; } - Dust expr_DC74_cp_0 = Main.dust[num299]; - expr_DC74_cp_0.velocity.X *= 3f; - Dust expr_DC94_cp_0 = Main.dust[num299]; - expr_DC94_cp_0.velocity.Y *= 3f; - Main.dust[num299].scale *= num296; + dust.velocity.X *= 3f; + dust.velocity.Y *= 3f; + dust.scale *= num296; } for (int num298 = 0; num298 < 2; num298++) { int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[num299]; if (Main.rand.NextBool(3)) { - Main.dust[num299].noGravity = true; - Main.dust[num299].scale *= 4f; - Dust expr_DBEF_cp_0 = Main.dust[num299]; - expr_DBEF_cp_0.velocity.X *= 4f; - Dust expr_DC0F_cp_0 = Main.dust[num299]; - expr_DC0F_cp_0.velocity.Y *= 4f; + dust.noGravity = true; + dust.scale *= 4f; + dust.velocity.X *= 4f; + dust.velocity.Y *= 4f; } else { - Main.dust[num299].scale *= 2.5f; + dust.scale *= 2.5f; } - Dust expr_DC74_cp_0 = Main.dust[num299]; - expr_DC74_cp_0.velocity.X *= 2f; - Dust expr_DC94_cp_0 = Main.dust[num299]; - expr_DC94_cp_0.velocity.Y *= 2f; - Main.dust[num299].scale *= num296; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + dust.scale *= num296; } } else diff --git a/Projectiles/Magic/Ancient2.cs b/Projectiles/Magic/Ancient2.cs index 59242d4a26..ac3cbc2292 100644 --- a/Projectiles/Magic/Ancient2.cs +++ b/Projectiles/Magic/Ancient2.cs @@ -51,42 +51,36 @@ namespace CalamityMod.Projectiles.Magic for (int num298 = 0; num298 < 2; num298++) { int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[num299]; if (Main.rand.NextBool(2)) { - Main.dust[num299].noGravity = true; - Main.dust[num299].scale *= 1.5f; - Dust expr_DBEF_cp_0 = Main.dust[num299]; - expr_DBEF_cp_0.velocity.X *= 3f; - Dust expr_DC0F_cp_0 = Main.dust[num299]; - expr_DC0F_cp_0.velocity.Y *= 3f; + dust.noGravity = true; + dust.scale *= 1.5f; + dust.velocity.X *= 3f; + dust.velocity.Y *= 3f; } - Dust expr_DC74_cp_0 = Main.dust[num299]; - expr_DC74_cp_0.velocity.X *= 2f; - Dust expr_DC94_cp_0 = Main.dust[num299]; - expr_DC94_cp_0.velocity.Y *= 2f; - Main.dust[num299].scale *= num296; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + dust.scale *= num296; } for (int num298 = 0; num298 < 2; num298++) { int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[num299]; if (Main.rand.NextBool(3)) { - Main.dust[num299].noGravity = true; - Main.dust[num299].scale *= 3f; - Dust expr_DBEF_cp_0 = Main.dust[num299]; - expr_DBEF_cp_0.velocity.X *= 2f; - Dust expr_DC0F_cp_0 = Main.dust[num299]; - expr_DC0F_cp_0.velocity.Y *= 2f; + dust.noGravity = true; + dust.scale *= 3f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; } else { - Main.dust[num299].scale *= 2f; + dust.scale *= 2f; } - Dust expr_DC74_cp_0 = Main.dust[num299]; - expr_DC74_cp_0.velocity.X *= 1.2f; - Dust expr_DC94_cp_0 = Main.dust[num299]; - expr_DC94_cp_0.velocity.Y *= 1.2f; - Main.dust[num299].scale *= num296; + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= num296; } } else diff --git a/Projectiles/Magic/AquamarineBolt.cs b/Projectiles/Magic/AquamarineBolt.cs index b02c21774b..fa855a7ebe 100644 --- a/Projectiles/Magic/AquamarineBolt.cs +++ b/Projectiles/Magic/AquamarineBolt.cs @@ -1,6 +1,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { @@ -9,12 +10,14 @@ namespace CalamityMod.Projectiles.Magic public override void SetStaticDefaults() { DisplayName.SetDefault("Bolt"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 2; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; } public override void SetDefaults() { - projectile.width = 8; - projectile.height = 8; + projectile.width = 16; + projectile.height = 16; projectile.friendly = true; projectile.ignoreWater = true; projectile.penetrate = 1; @@ -24,27 +27,26 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.25f / 255f, (255 - projectile.alpha) * 0.25f / 255f); - for (int num151 = 0; num151 < 3; num151++) - { - int num154 = 14; - int num155 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width - num154 * 2, projectile.height - num154 * 2, 68, 0f, 0f, 100, default, 1.5f); - Main.dust[num155].noGravity = true; - Main.dust[num155].velocity *= 0.1f; - Main.dust[num155].velocity += projectile.velocity * 0.5f; - } - if (Main.rand.NextBool(8)) + int num154 = 14; + int num155 = Dust.NewDust(projectile.Center, projectile.width - num154 * 2, projectile.height - num154 * 2, 68, 0f, 0f, 100, default, 1.5f); + Main.dust[num155].noGravity = true; + Main.dust[num155].velocity *= 0.1f; + Main.dust[num155].velocity += projectile.velocity * 0.5f; + if (Main.rand.NextBool(16)) { int num156 = 16; - int num157 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width - num156 * 2, projectile.height - num156 * 2, 68, 0f, 0f, 100, default, 1f); + int num157 = Dust.NewDust(projectile.Center, projectile.width - num156 * 2, projectile.height - num156 * 2, 68, 0f, 0f, 100, default, 1f); Main.dust[num157].velocity *= 0.25f; Main.dust[num157].velocity += projectile.velocity * 0.5f; } + projectile.rotation += 0.3f * (float)projectile.direction; } + public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 200); + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D tex = Main.projectileTexture[projectile.type]; - spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); return false; } } diff --git a/Projectiles/Magic/AquamarineBolt.png b/Projectiles/Magic/AquamarineBolt.png index 0056fc1e24..bfb8c86d2a 100644 Binary files a/Projectiles/Magic/AquamarineBolt.png and b/Projectiles/Magic/AquamarineBolt.png differ diff --git a/Projectiles/Magic/AuraRain.cs b/Projectiles/Magic/AuraRain.cs index 486a150678..cbba29991f 100644 --- a/Projectiles/Magic/AuraRain.cs +++ b/Projectiles/Magic/AuraRain.cs @@ -1,5 +1,8 @@ using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { @@ -12,8 +15,8 @@ namespace CalamityMod.Projectiles.Magic public override void SetDefaults() { - projectile.width = 2; - projectile.height = 2; + projectile.width = 10; + projectile.height = 10; projectile.aiStyle = 45; projectile.friendly = true; projectile.penetrate = -1; @@ -23,17 +26,25 @@ namespace CalamityMod.Projectiles.Magic projectile.scale = 1.1f; projectile.magic = true; projectile.extraUpdates = 1; - aiType = 239; + aiType = ProjectileID.RainFriendly; } public override void AI() { - Dust dust4 = Main.dust[Dust.NewDust(projectile.position, projectile.width, projectile.height, 14, projectile.velocity.X, projectile.velocity.Y, 100, default, 1f)]; - dust4.velocity = Vector2.Zero; - dust4.position -= projectile.velocity / 5f; - dust4.noGravity = true; - dust4.scale = 0.8f; - dust4.noLight = true; + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) - MathHelper.PiOver2; + Dust dust = Main.dust[Dust.NewDust(projectile.position, projectile.width, projectile.height, 14, projectile.velocity.X, projectile.velocity.Y, 100, default, 1f)]; + dust.velocity = Vector2.Zero; + dust.position -= projectile.velocity / 5f; + dust.noGravity = true; + dust.scale = 0.8f; + dust.noLight = true; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D tex = Main.projectileTexture[projectile.type]; + spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); + return false; } } } diff --git a/Projectiles/Magic/AuraRain.png b/Projectiles/Magic/AuraRain.png index 0c09522090..f129a7b060 100644 Binary files a/Projectiles/Magic/AuraRain.png and b/Projectiles/Magic/AuraRain.png differ diff --git a/Projectiles/Magic/BloodBlast.cs b/Projectiles/Magic/BloodBlast.cs index 54f577681c..61ccc5e742 100644 --- a/Projectiles/Magic/BloodBlast.cs +++ b/Projectiles/Magic/BloodBlast.cs @@ -33,13 +33,12 @@ namespace CalamityMod.Projectiles.Magic float num94 = projectile.velocity.Y / 3f * (float)num92; int num95 = 4; int num96 = Dust.NewDust(new Vector2(projectile.position.X + (float)num95, projectile.position.Y + (float)num95), projectile.width - num95 * 2, projectile.height - num95 * 2, 5, 0f, 0f, 100, default, 1.2f); - Main.dust[num96].noGravity = true; - Main.dust[num96].velocity *= 0.1f; - Main.dust[num96].velocity += projectile.velocity * 0.1f; - Dust expr_47FA_cp_0 = Main.dust[num96]; - expr_47FA_cp_0.position.X -= num93; - Dust expr_4815_cp_0 = Main.dust[num96]; - expr_4815_cp_0.position.Y -= num94; + Dust dust = Main.dust[num96]; + dust.noGravity = true; + dust.velocity *= 0.1f; + dust.velocity += projectile.velocity * 0.1f; + dust.position.X -= num93; + dust.position.Y -= num94; } if (Main.rand.NextBool(5)) { diff --git a/Projectiles/Magic/BrimstoneHellfireballFriendly.cs b/Projectiles/Magic/BrimstoneHellfireballFriendly.cs index 23721e7d31..2a104cafb5 100644 --- a/Projectiles/Magic/BrimstoneHellfireballFriendly.cs +++ b/Projectiles/Magic/BrimstoneHellfireballFriendly.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,6 +12,9 @@ namespace CalamityMod.Projectiles.Magic public override void SetStaticDefaults() { DisplayName.SetDefault("Hellfire"); + Main.projFrames[projectile.type] = 6; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; } public override void SetDefaults() @@ -29,19 +33,39 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - Lighting.AddLight(projectile.Center, 0.6f, 0f, 0f); + //Animation + projectile.frameCounter++; + if (projectile.frameCounter > 9) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= 6) + { + projectile.frame = 0; + } + + //Fade in + if (projectile.alpha > 5) + projectile.alpha -= 15; + if (projectile.alpha < 5) + projectile.alpha = 5; + + //Rotation + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) - MathHelper.ToRadians(90) * projectile.direction; + + int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 170, default, 1.1f); + Main.dust[num458].noGravity = true; + Main.dust[num458].velocity *= 0.5f; + Main.dust[num458].velocity += projectile.velocity * 0.1f; + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.05f / 255f, (255 - projectile.alpha) * 0.05f / 255f); + if (projectile.localAI[0] == 0f) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20); projectile.localAI[0] += 1f; } - for (int num457 = 0; num457 < 3; num457++) - { - int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += projectile.velocity * 0.1f; - } } public override void Kill(int timeLeft) @@ -56,5 +80,11 @@ namespace CalamityMod.Projectiles.Magic { target.AddBuff(ModContent.BuffType(), 600); } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); + return false; + } } } diff --git a/Projectiles/Magic/BrimstoneHellfireballFriendly.png b/Projectiles/Magic/BrimstoneHellfireballFriendly.png index 831f72cfc8..71720f8c11 100644 Binary files a/Projectiles/Magic/BrimstoneHellfireballFriendly.png and b/Projectiles/Magic/BrimstoneHellfireballFriendly.png differ diff --git a/Projectiles/Magic/DarkSparkPrism.cs b/Projectiles/Magic/DarkSparkPrism.cs index bdcff0a9db..d3638d596b 100644 --- a/Projectiles/Magic/DarkSparkPrism.cs +++ b/Projectiles/Magic/DarkSparkPrism.cs @@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Magic { num26 = 5f; } - projectile.damage = (int)((float)player.inventory[player.selectedItem].damage * player.magicDamage); + projectile.damage = (int)(player.ActiveItem().damage * player.MagicDamage()); projectile.ai[0] += 1f; projectile.ai[1] += 1f; if (projectile.localAI[0] == 0f) @@ -87,7 +87,7 @@ namespace CalamityMod.Projectiles.Magic flag10 = true; if (Main.myPlayer == projectile.owner) { - float scaleFactor5 = player.inventory[player.selectedItem].shootSpeed * projectile.scale; + float scaleFactor5 = player.ActiveItem().shootSpeed * projectile.scale; Vector2 value12 = vector; Vector2 value13 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - value12; if (player.gravDir == -1f) @@ -129,7 +129,7 @@ namespace CalamityMod.Projectiles.Magic } if (flag10 && Main.myPlayer == projectile.owner) { - bool flag11 = !flag9 || player.CheckMana(player.inventory[player.selectedItem].mana, true, false); + bool flag11 = !flag9 || player.CheckMana(player.ActiveItem().mana, true, false); bool flag12 = player.channel && flag11 && !player.noItems && !player.CCed; if (flag12) { diff --git a/Projectiles/Magic/DarkSparkPrism.png b/Projectiles/Magic/DarkSparkPrism.png index df1fa170eb..b082a2a1f4 100644 Binary files a/Projectiles/Magic/DarkSparkPrism.png and b/Projectiles/Magic/DarkSparkPrism.png differ diff --git a/Projectiles/Magic/DivineRetributionSpear.cs b/Projectiles/Magic/DivineRetributionSpear.cs index e7eb11bab2..0bf105abfc 100644 --- a/Projectiles/Magic/DivineRetributionSpear.cs +++ b/Projectiles/Magic/DivineRetributionSpear.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Magic return; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 9f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 9f, 20f); } else { diff --git a/Projectiles/Magic/GhastlyVisageProj.cs b/Projectiles/Magic/GhastlyVisageProj.cs index d867918511..1ee6267dcb 100644 --- a/Projectiles/Magic/GhastlyVisageProj.cs +++ b/Projectiles/Magic/GhastlyVisageProj.cs @@ -146,12 +146,12 @@ namespace CalamityMod.Projectiles.Magic { int num42 = ModContent.ProjectileType(); float scaleFactor11 = 6f; - int weaponDamage2 = player.GetWeaponDamage(player.inventory[player.selectedItem]); - float weaponKnockback2 = player.inventory[player.selectedItem].knockBack; + int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); + float weaponKnockback2 = player.ActiveItem().knockBack; if (flag16) { - weaponKnockback2 = player.GetWeaponKnockback(player.inventory[player.selectedItem], weaponKnockback2); - float scaleFactor12 = player.inventory[player.selectedItem].shootSpeed * projectile.scale; + weaponKnockback2 = player.GetWeaponKnockback(player.ActiveItem(), weaponKnockback2); + float scaleFactor12 = player.ActiveItem().shootSpeed * projectile.scale; Vector2 vector19 = vector; Vector2 value18 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - vector19; if (player.gravDir == -1f) diff --git a/Projectiles/Magic/GranitePulse.cs b/Projectiles/Magic/GranitePulse.cs index 4f506078c8..2c1bd265d8 100644 --- a/Projectiles/Magic/GranitePulse.cs +++ b/Projectiles/Magic/GranitePulse.cs @@ -6,7 +6,6 @@ namespace CalamityMod.Projectiles.Magic { public class GranitePulse : ModProjectile { - public int pulse = 49; public float count = 0f; public override void SetStaticDefaults() @@ -46,7 +45,7 @@ namespace CalamityMod.Projectiles.Magic int num417 = 0; float num418 = 0f; int num419 = projectile.type; - for (int num420 = 0; num420 < 1000; num420++) + for (int num420 = 0; num420 < Main.maxProjectiles; num420++) { if (Main.projectile[num420].active && Main.projectile[num420].owner == projectile.owner && Main.projectile[num420].type == num419 && Main.projectile[num420].ai[1] < 3600f) { @@ -94,8 +93,7 @@ namespace CalamityMod.Projectiles.Magic } count += 1f; } - pulse--; - if (pulse == 0) + if (projectile.timeLeft % 50 == 49) { Main.PlaySound(3, (int)projectile.position.X, (int)projectile.position.Y, 53); projectile.position.X = projectile.position.X + (float)(projectile.width / 2); @@ -122,7 +120,6 @@ namespace CalamityMod.Projectiles.Magic num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 206, 0f, 0f, 100, default, 0.5f); Main.dust[num624].velocity *= 2f; } - pulse = 50; float spread = 45f * 0.0174f; double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; diff --git a/Projectiles/Magic/MelterAmp.cs b/Projectiles/Magic/MelterAmp.cs index 67fbeac7fa..ece39897a6 100644 --- a/Projectiles/Magic/MelterAmp.cs +++ b/Projectiles/Magic/MelterAmp.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.Magic projectile.active = false; return; } - if (!player.inventory[player.selectedItem].magic || player.inventory[player.selectedItem].shoot != ModContent.ProjectileType()) + if (!player.ActiveItem().magic || player.ActiveItem().shoot != ModContent.ProjectileType()) { projectile.active = false; return; diff --git a/Projectiles/Magic/PhantasmalFuryProj.cs b/Projectiles/Magic/PhantasmalFuryProj.cs index 1af8779631..c34d016372 100644 --- a/Projectiles/Magic/PhantasmalFuryProj.cs +++ b/Projectiles/Magic/PhantasmalFuryProj.cs @@ -6,8 +6,6 @@ namespace CalamityMod.Projectiles.Magic { public class PhantasmalFuryProj : ModProjectile { - int lightTimer = 10; - public override void SetStaticDefaults() { DisplayName.SetDefault("Fury"); @@ -26,14 +24,12 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - lightTimer--; - if (lightTimer == 0) + if (projectile.timeLeft % 10 == 0) { if (projectile.owner == Main.myPlayer) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); } - lightTimer = 10; } Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.25f / 255f, (255 - projectile.alpha) * 0.25f / 255f, (255 - projectile.alpha) * 0.25f / 255f); for (int num457 = 0; num457 < 5; num457++) diff --git a/Projectiles/Magic/PlasmaRay.cs b/Projectiles/Magic/PlasmaRay.cs index cac4ab9437..9855922413 100644 --- a/Projectiles/Magic/PlasmaRay.cs +++ b/Projectiles/Magic/PlasmaRay.cs @@ -66,8 +66,8 @@ namespace CalamityMod.Projectiles.Magic for (i = 0; i < 4; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)((double)projectile.damage * 1.75), projectile.knockBack, projectile.owner, 0f, 0f); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)((double)projectile.damage * 1.75), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)(projectile.damage * 1.75), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)(projectile.damage * 1.75), projectile.knockBack, projectile.owner, 0f, 0f); } } projectile.penetrate--; diff --git a/Projectiles/Magic/PurgeProj.cs b/Projectiles/Magic/PurgeProj.cs index 6f18cc87a5..b14f401183 100644 --- a/Projectiles/Magic/PurgeProj.cs +++ b/Projectiles/Magic/PurgeProj.cs @@ -75,11 +75,11 @@ namespace CalamityMod.Projectiles.Magic } if (flag && Main.myPlayer == projectile.owner) { - int weaponDamage2 = player.GetWeaponDamage(player.inventory[player.selectedItem]); - bool flag2 = player.channel && player.CheckMana(player.inventory[player.selectedItem].mana, true, false) && !player.noItems && !player.CCed; + int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); + bool flag2 = player.channel && player.CheckMana(player.ActiveItem().mana, true, false) && !player.noItems && !player.CCed; if (flag2) { - float scaleFactor = player.inventory[player.selectedItem].shootSpeed * projectile.scale; + float scaleFactor = player.ActiveItem().shootSpeed * projectile.scale; Vector2 value2 = vector; Vector2 value3 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - value2; if (player.gravDir == -1f) diff --git a/Projectiles/Magic/SerpentineBody.cs b/Projectiles/Magic/SerpentineBody.cs index 6b1265b69a..27134eaf2f 100644 --- a/Projectiles/Magic/SerpentineBody.cs +++ b/Projectiles/Magic/SerpentineBody.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { @@ -8,6 +9,7 @@ namespace CalamityMod.Projectiles.Magic public override void SetStaticDefaults() { DisplayName.SetDefault("Serpentine"); + ProjectileID.Sets.NeedsUUID[projectile.type] = true; } public override void SetDefaults() @@ -35,7 +37,7 @@ namespace CalamityMod.Projectiles.Magic projectile.ai[1] = 0f; projectile.netUpdate = true; } - int chase = (int)projectile.ai[0]; + int chase = Projectile.GetByUUID(projectile.owner, (int)projectile.ai[0]); float num1064; float scaleFactor17; float scaleFactor18; diff --git a/Projectiles/Magic/SerpentineHead.cs b/Projectiles/Magic/SerpentineHead.cs index e9774ac928..bab40332fe 100644 --- a/Projectiles/Magic/SerpentineHead.cs +++ b/Projectiles/Magic/SerpentineHead.cs @@ -8,11 +8,10 @@ namespace CalamityMod.Projectiles.Magic { public class SerpentineHead : ModProjectile { - - public override void SetStaticDefaults() { DisplayName.SetDefault("Serpentine"); + ProjectileID.Sets.NeedsUUID[projectile.type] = true; } public override void SetDefaults() diff --git a/Projectiles/Magic/SerpentineTail.cs b/Projectiles/Magic/SerpentineTail.cs index a4396b4017..011a9eb155 100644 --- a/Projectiles/Magic/SerpentineTail.cs +++ b/Projectiles/Magic/SerpentineTail.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { @@ -8,6 +9,7 @@ namespace CalamityMod.Projectiles.Magic public override void SetStaticDefaults() { DisplayName.SetDefault("Serpentine"); + ProjectileID.Sets.NeedsUUID[projectile.type] = true; } public override void SetDefaults() @@ -35,7 +37,7 @@ namespace CalamityMod.Projectiles.Magic projectile.ai[1] = 0f; projectile.netUpdate = true; } - int chase = (int)projectile.ai[0]; + int chase = Projectile.GetByUUID(projectile.owner, (int)projectile.ai[0]); float num1064; float scaleFactor17; float scaleFactor18; diff --git a/Projectiles/Magic/ShiftingSandsProj.cs b/Projectiles/Magic/ShiftingSandsProj.cs index 08bd36ca4d..409ada1f6e 100644 --- a/Projectiles/Magic/ShiftingSandsProj.cs +++ b/Projectiles/Magic/ShiftingSandsProj.cs @@ -23,6 +23,9 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.penetrate = 5; projectile.magic = true; + projectile.extraUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; } public override void AI() @@ -157,10 +160,5 @@ namespace CalamityMod.Projectiles.Magic Main.dust[num228].velocity = vector7; } } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 5; - } } } diff --git a/Projectiles/Magic/SparklingBeam.cs b/Projectiles/Magic/SparklingBeam.cs index b536965a93..c36d09d386 100644 --- a/Projectiles/Magic/SparklingBeam.cs +++ b/Projectiles/Magic/SparklingBeam.cs @@ -238,7 +238,7 @@ namespace CalamityMod.Projectiles.Magic } else { // Do we still have enough mana? If not, we kill the projectile because we cannot use it anymore - if (Main.time % 10 < 1 && !player.CheckMana(player.inventory[player.selectedItem].mana, true)) + if (Main.time % 10 < 1 && !player.CheckMana(player.ActiveItem().mana, true)) { projectile.Kill(); } diff --git a/Projectiles/Magic/SupremeDustFlakProjectile.cs b/Projectiles/Magic/SupremeDustFlakProjectile.cs index 12bb4bfb0b..a45db701e3 100644 --- a/Projectiles/Magic/SupremeDustFlakProjectile.cs +++ b/Projectiles/Magic/SupremeDustFlakProjectile.cs @@ -46,46 +46,40 @@ namespace CalamityMod.Projectiles.Magic for (int num298 = 0; num298 < 2; num298++) { int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[num299]; if (Main.rand.NextBool(3)) { - Main.dust[num299].noGravity = false; - Main.dust[num299].scale *= 1f; - Dust expr_DBEF_cp_0 = Main.dust[num299]; - expr_DBEF_cp_0.velocity.X *= 2f; - Dust expr_DC0F_cp_0 = Main.dust[num299]; - expr_DC0F_cp_0.velocity.Y *= 2f; + dust.noGravity = false; + dust.scale *= 1f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; } else { - Main.dust[num299].scale *= 0.5f; + dust.scale *= 0.5f; } - Dust expr_DC74_cp_0 = Main.dust[num299]; - expr_DC74_cp_0.velocity.X *= 1.2f; - Dust expr_DC94_cp_0 = Main.dust[num299]; - expr_DC94_cp_0.velocity.Y *= 1.2f; - Main.dust[num299].scale *= num296; + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= num296; } for (int num298 = 0; num298 < 2; num298++) { int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[num299]; if (Main.rand.NextBool(3)) { - Main.dust[num299].noGravity = false; - Main.dust[num299].scale *= 1.5f; - Dust expr_DBEF_cp_0 = Main.dust[num299]; - expr_DBEF_cp_0.velocity.X *= 2f; - Dust expr_DC0F_cp_0 = Main.dust[num299]; - expr_DC0F_cp_0.velocity.Y *= 2f; + dust.noGravity = false; + dust.scale *= 1.5f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; } else { - Main.dust[num299].scale *= 0.25f; + dust.scale *= 0.25f; } - Dust expr_DC74_cp_0 = Main.dust[num299]; - expr_DC74_cp_0.velocity.X *= 1.2f; - Dust expr_DC94_cp_0 = Main.dust[num299]; - expr_DC94_cp_0.velocity.Y *= 1.2f; - Main.dust[num299].scale *= num296; + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= num296; } } else diff --git a/Projectiles/Magic/SupremeDustProjectile.cs b/Projectiles/Magic/SupremeDustProjectile.cs index 0e0ac64c3d..6ecf7f4eb9 100644 --- a/Projectiles/Magic/SupremeDustProjectile.cs +++ b/Projectiles/Magic/SupremeDustProjectile.cs @@ -43,44 +43,38 @@ namespace CalamityMod.Projectiles.Magic } projectile.ai[0] += 1f; int num297 = 32; - int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); - if (Main.rand.NextBool(3)) - { - Main.dust[num299].noGravity = true; - Main.dust[num299].scale *= 4f; - Dust expr_DBEF_cp_0 = Main.dust[num299]; - expr_DBEF_cp_0.velocity.X *= 2f; - Dust expr_DC0F_cp_0 = Main.dust[num299]; - expr_DC0F_cp_0.velocity.Y *= 2f; - } - else - { - Main.dust[num299].scale *= 2.5f; - } - Dust expr_DC74_cp_0 = Main.dust[num299]; - expr_DC74_cp_0.velocity.X *= 1.2f; - Dust expr_DC94_cp_0 = Main.dust[num299]; - expr_DC94_cp_0.velocity.Y *= 1.2f; - Main.dust[num299].scale *= num296; + int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[num299]; + if (Main.rand.NextBool(2)) + { + dust.noGravity = true; + dust.scale *= 4f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + else + { + dust.scale *= 2.5f; + } + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= num296; int num399 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust2 = Main.dust[num399]; if (Main.rand.NextBool(3)) { - Main.dust[num399].noGravity = true; - Main.dust[num399].scale *= 6f; - Dust expr_DBEF_cp_0 = Main.dust[num399]; - expr_DBEF_cp_0.velocity.X *= 2f; - Dust expr_DC0F_cp_0 = Main.dust[num399]; - expr_DC0F_cp_0.velocity.Y *= 2f; + dust2.noGravity = true; + dust2.scale *= 6f; + dust2.velocity.X *= 2f; + dust2.velocity.Y *= 2f; } else { - Main.dust[num399].scale *= 2.5f; + dust2.scale *= 2.5f; } - Dust expr_DC74_cp_1 = Main.dust[num399]; - expr_DC74_cp_1.velocity.X *= 1.2f; - Dust expr_DC94_cp_1 = Main.dust[num399]; - expr_DC94_cp_1.velocity.Y *= 1.2f; - Main.dust[num399].scale *= num296; + dust2.velocity.X *= 1.2f; + dust2.velocity.Y *= 1.2f; + dust2.scale *= num296; } else { diff --git a/Projectiles/Magic/T1000Proj.cs b/Projectiles/Magic/T1000Proj.cs index 4147e4f8c8..99104817dc 100644 --- a/Projectiles/Magic/T1000Proj.cs +++ b/Projectiles/Magic/T1000Proj.cs @@ -75,11 +75,11 @@ namespace CalamityMod.Projectiles.Magic } if (flag && Main.myPlayer == projectile.owner) { - int weaponDamage2 = player.GetWeaponDamage(player.inventory[player.selectedItem]); - bool flag2 = player.channel && player.CheckMana(player.inventory[player.selectedItem].mana, true, false) && !player.noItems && !player.CCed; + int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); + bool flag2 = player.channel && player.CheckMana(player.ActiveItem().mana, true, false) && !player.noItems && !player.CCed; if (flag2) { - float scaleFactor = player.inventory[player.selectedItem].shootSpeed * projectile.scale; + float scaleFactor = player.ActiveItem().shootSpeed * projectile.scale; Vector2 value2 = vector; Vector2 value3 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - value2; if (player.gravDir == -1f) diff --git a/Projectiles/Magic/UndinesRetributionSpear.cs b/Projectiles/Magic/UndinesRetributionSpear.cs index 3fcf1ad3b5..f001ca983d 100644 --- a/Projectiles/Magic/UndinesRetributionSpear.cs +++ b/Projectiles/Magic/UndinesRetributionSpear.cs @@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Magic return; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 9f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 9f, 20f); } else { @@ -102,6 +102,7 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; + projectile.damage /= 2; projectile.Damage(); Main.PlaySound(2, (int)projectile.Center.X, (int)projectile.Center.Y, 21, 1f, 0f); for (int num193 = 0; num193 < 4; num193++) diff --git a/Projectiles/Magic/ValkyrieRayBeam.cs b/Projectiles/Magic/ValkyrieRayBeam.cs new file mode 100644 index 0000000000..57be18cc03 --- /dev/null +++ b/Projectiles/Magic/ValkyrieRayBeam.cs @@ -0,0 +1,227 @@ +using CalamityMod.Items.Weapons.Magic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.Enums; +using Terraria.GameContent.Shaders; +using Terraria.Graphics.Effects; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class ValkyrieRayBeam : ModProjectile + { + private const int Lifetime = 24; + private const int BeamDustID = 73; + + private const float MaxBeamScale = 1.2f; + + private const float MaxBeamLength = 2400f; + private const float BeamTileCollisionWidth = 1f; + private const float BeamHitboxCollisionWidth = 15f; + private const int NumSamplePoints = 3; + private const float BeamLengthChangeFactor = 0.75f; + + private const float OuterBeamOpacityMultiplier = 0.82f; + private const float InnerBeamOpacityMultiplier = 0.2f; + private const float MaxBeamBrightness = 0.75f; + + private const float MainDustBeamEndOffset = 14.5f; + private const float SidewaysDustBeamEndOffset = 4f; + private const float BeamRenderTileOffset = 10.5f; + private const float BeamLengthReductionFactor = 14.5f; + + private Vector2 beamVector = Vector2.Zero; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Valkyrie Ray"); + } + + public override void SetDefaults() + { + projectile.width = 16; + projectile.height = 16; + projectile.friendly = true; + projectile.magic = true; + projectile.penetrate = -1; + projectile.alpha = 0; + // The beam itself still stops on tiles, but its invisible "source" projectile ignores them. + projectile.tileCollide = false; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 4; + + // The beam lasts for only some frames and fades out over that time. + projectile.timeLeft = Lifetime; + } + + // projectile.ai[0] = Length of the beam (dynamically recalculated every frame in case someone breaks or places some blocks) + public override void AI() + { + // If the projectile for some reason isn't still a Valkyrie Ray, delete it immediately. + if (projectile.type != ModContent.ProjectileType()) + { + projectile.Kill(); + return; + } + + // On frame 1, set the beam vector and rotation, but set the real velocity to zero. + if(projectile.velocity != Vector2.Zero) + { + beamVector = Vector2.Normalize(projectile.velocity); + projectile.rotation = projectile.velocity.ToRotation(); + projectile.velocity = Vector2.Zero; + } + + // Reduce the "power" and thus scale of the projectile over its lifetime. + float power = (float)projectile.timeLeft / Lifetime; + projectile.scale = MaxBeamScale * power; + + // Perform a laser scan to calculate the correct length of the beam. + float[] laserScanResults = new float[NumSamplePoints]; + + // A minimum width is forced for the beam scan to prevent massive lag when fired into open areas. + float scanWidth = projectile.scale < 1f ? 1f : projectile.scale; + Collision.LaserScan(projectile.Center, beamVector, BeamTileCollisionWidth * scanWidth, MaxBeamLength, laserScanResults); + float avg = 0f; + for (int i = 0; i < laserScanResults.Length; ++i) + avg += laserScanResults[i]; + avg /= NumSamplePoints; + projectile.ai[0] = MathHelper.Lerp(projectile.ai[0], avg, BeamLengthChangeFactor); + + // X = beam length. Y = beam width. + Vector2 beamDims = new Vector2(beamVector.Length() * projectile.ai[0], projectile.width * projectile.scale); + + Color beamColor = GetBeamColor(); + ProduceBeamDust(beamColor); + + // If the game is rendering (i.e. isn't a dedicated server), make the beam disturb water. + if (Main.netMode != NetmodeID.Server) + { + WaterShaderData wsd = (WaterShaderData)Filters.Scene["WaterDistortion"].GetShader(); + // A universal time-based sinusoid which updates extremely rapidly. GlobalTime is 0 to 3600, measured in seconds. + float waveSine = 0.1f * (float)Math.Sin(Main.GlobalTime * 20f); + Vector2 ripplePos = projectile.position + new Vector2(beamDims.X * 0.5f, 0f).RotatedBy(projectile.rotation); + // WaveData is encoded as a Color. Not sure why, considering Vector3 exists. + Color waveData = new Color(0.5f, 0.1f * Math.Sign(waveSine) + 0.5f, 0f, 1f) * Math.Abs(waveSine); + wsd.QueueRipple(ripplePos, waveData, beamDims, RippleShape.Square, projectile.rotation); + } + + // Make the beam cast light along its length. + // v3_1 is an unnamed decompiled variable which is the color of the light cast by DelegateMethods.CastLight + DelegateMethods.v3_1 = beamColor.ToVector3() * power * MaxBeamBrightness; + Utils.PlotTileLine(projectile.Center, projectile.Center + beamVector * projectile.ai[0], beamDims.Y, new Utils.PerLinePoint(DelegateMethods.CastLight)); + } + + // Determines whether the specified target hitbox is intersecting with the beam. + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + // If the target is touching the beam's hitbox (which is a small rectangle vaguely overlapping the host crystal), that's good enough. + if (projHitbox.Intersects(targetHitbox)) + return true; + // Otherwise, perform an AABB line collision check to check the whole beam. + float _ = float.NaN; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + beamVector * projectile.ai[0], BeamHitboxCollisionWidth * projectile.scale, ref _); + } + + private Color GetBeamColor() + { + Color c = ValkyrieRay.LightColor; + c.A = 64; + return c; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + // If the beam doesn't have a defined projection vector or hasn't yet had its velocity set to zero, don't draw anything. + if (beamVector == Vector2.Zero || projectile.velocity != Vector2.Zero) + return false; + + Texture2D tex = Main.projectileTexture[projectile.type]; + float beamLength = projectile.ai[0]; + Vector2 centerFloored = projectile.Center.Floor() + beamVector * projectile.scale * BeamRenderTileOffset; + Vector2 scaleVec = new Vector2(projectile.scale); + + // Reduce the beam length proportional to its square area to reduce block penetration. + beamLength -= BeamLengthReductionFactor * projectile.scale * projectile.scale; + + DelegateMethods.f_1 = 1f; // f_1 is an unnamed decompiled variable whose function is unknown. Leave it at 1. + Vector2 beamStartPos = centerFloored - Main.screenPosition; + Vector2 beamEndPos = beamStartPos + beamVector * beamLength; + Utils.LaserLineFraming llf = new Utils.LaserLineFraming(DelegateMethods.RainbowLaserDraw); + + // Draw the outermost beam + // c_1 is an unnamed decompiled variable which is the render color of the beam drawn by DelegateMethods.RainbowLaserDraw + Color beamColor = GetBeamColor(); + DelegateMethods.c_1 = beamColor * OuterBeamOpacityMultiplier * projectile.Opacity; + Utils.DrawLaser(Main.spriteBatch, tex, beamStartPos, beamEndPos, scaleVec, llf); + + // Draw the inner beams, each with reduced size and whiter color + for (int i = 0; i < 5; ++i) + { + beamColor = Color.Lerp(beamColor, Color.White, 0.4f); + scaleVec *= 0.85f; + DelegateMethods.c_1 = beamColor * InnerBeamOpacityMultiplier * projectile.Opacity; + Utils.DrawLaser(Main.spriteBatch, tex, beamStartPos, beamEndPos, scaleVec, llf); + } + return false; + } + + private void ProduceBeamDust(Color beamColor) + { + // Create a few dust per frame a small distance from where the beam ends. + Vector2 laserEndPos = projectile.Center + beamVector * (projectile.ai[0] - MainDustBeamEndOffset * projectile.scale); + for (int i = 0; i < 2; ++i) + { + // 50% chance for the dust to come off on either side of the beam. + float dustAngle = projectile.rotation + (Main.rand.NextBool() ? 1f : -1f) * MathHelper.PiOver2; + float dustStartDist = Main.rand.NextFloat(1f, 1.8f); + Vector2 dustVel = dustAngle.ToRotationVector2() * dustStartDist; + int d = Dust.NewDust(laserEndPos, 0, 0, BeamDustID, dustVel.X, dustVel.Y, 0, beamColor); + Main.dust[d].color = beamColor; + Main.dust[d].noGravity = true; + Main.dust[d].scale = 0.7f; + + // Scale up dust with the projectile if it's large. + if (projectile.scale > 1f) + { + Main.dust[d].velocity *= projectile.scale; + Main.dust[d].scale *= projectile.scale; + } + + // If the beam isn't at max scale, then make additional smaller dust. + if (projectile.scale != MaxBeamScale) + { + Dust smallDust = Dust.CloneDust(d); + smallDust.scale /= 2f; + } + } + + // Low chance every frame to spawn a large "directly sideways" dust which doesn't move. + if (Main.rand.NextBool(5)) + { + // Velocity, flipped sideways, times -50% to 50% of beam width. + Vector2 dustOffset = beamVector.RotatedBy(MathHelper.PiOver2) * (Main.rand.NextFloat() - 0.5f) * projectile.width; + Vector2 dustPos = laserEndPos + dustOffset - Vector2.One * SidewaysDustBeamEndOffset; + int d = Dust.NewDust(dustPos, 8, 8, BeamDustID, 0f, 0f, 100, beamColor, 1.2f); + Main.dust[d].velocity *= 0.5f; + + // Force the dust to always move downwards, never upwards. + Main.dust[d].velocity.Y = -Math.Abs(Main.dust[d].velocity.Y); + } + } + + // Automatically iterates through every tile the laser is overlapping to cut grass at all those locations. + public override void CutTiles() + { + // tilecut_0 is an unnamed decompiled variable which tells CutTiles how the tiles are being cut (in this case, via a projectile). + DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; + Utils.PerLinePoint cut = new Utils.PerLinePoint(DelegateMethods.CutTiles); + Vector2 beamStartPos = projectile.Center; + Vector2 beamEndPos = beamStartPos + beamVector * projectile.ai[0]; + Utils.PlotTileLine(beamStartPos, beamEndPos, projectile.width * projectile.scale, cut); + } + } +} diff --git a/Projectiles/Magic/ValkyrieRayBeam.png b/Projectiles/Magic/ValkyrieRayBeam.png new file mode 100644 index 0000000000..4bcb09bbf2 Binary files /dev/null and b/Projectiles/Magic/ValkyrieRayBeam.png differ diff --git a/Projectiles/Magic/ValkyrieRayStaff.cs b/Projectiles/Magic/ValkyrieRayStaff.cs new file mode 100644 index 0000000000..6f4fd13085 --- /dev/null +++ b/Projectiles/Magic/ValkyrieRayStaff.cs @@ -0,0 +1,144 @@ +using CalamityMod.Items.Weapons.Magic; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class ValkyrieRayStaff : ModProjectile + { + private const float AimResponsiveness = 0.66f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Valkyrie Ray"); + } + + public override void SetDefaults() + { + projectile.width = 54; + projectile.height = 52; + // This projectile has no hitboxes and no damage type. + projectile.friendly = false; + projectile.melee = false; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 900; + } + + // ai[0] is a time-dilated frame counter. ai[1] is whether the beam has already fired. + // localAI[0] is the rate at which the "frame" counter increases. + public override void AI() + { + Player player = Main.player[projectile.owner]; + Vector2 rrp = player.RotatedRelativePoint(player.MountedCenter, true); + + // Calculate how quickly the staff should charge. Charge increases by some number close to 1 every frame. + // Speed increasing reforges make this number greater than 1. Slowing reforges make it smaller than 1. + if (projectile.localAI[0] == 0f) + projectile.localAI[0] = 47f / player.ActiveItem().useTime; + + // Increment the timer for the staff. If the timer has passed 47, destroy it. + projectile.ai[0] += projectile.localAI[0]; + int maxTime = ValkyrieRay.ChargeFrames + ValkyrieRay.CooldownFrames; + if (projectile.ai[0] > maxTime) + { + projectile.Kill(); + return; + } + + // Compute the weapon's charge. + float chargeLevel = MathHelper.Clamp(projectile.ai[0] / ValkyrieRay.ChargeFrames, 0f, 1f); + + // Common code among holdouts to keep the holdout projectile directly in the player's hand + UpdatePlayerVisuals(player, rrp); + + // Compute the gem position, which is needed for visual effects + float angle = projectile.rotation - MathHelper.PiOver2; + Vector2 gemOffset = Vector2.One * ValkyrieRay.GemDistance * 1.4142f; // distance to gem on staff + Vector2 gemPos = projectile.Center + gemOffset.RotatedBy(angle); + + // Firing or charging? + if (chargeLevel >= 1f && projectile.ai[1] == 0f) + { + projectile.ai[1] = 1f; // so it never fires again + FiringEffects(gemPos); + if (projectile.owner == Main.myPlayer) + { + Projectile laser = Projectile.NewProjectileDirect(gemPos, projectile.velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + laser.Center = gemPos; + } + } + else if (projectile.ai[1] == 0f) + { + // The player can constantly re-aim the staff while it's charging, but once it fires it is locked in place. + UpdateAim(rrp, projectile.velocity.Length()); + ChargingEffects(gemPos, chargeLevel); + } + } + + private void UpdatePlayerVisuals(Player player, Vector2 rrp) + { + // Place the projectile directly into the player's hand at all times + projectile.Center = rrp; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; + + // The staff is a holdout projectile, so change the player's variables to reflect that + player.ChangeDir(projectile.direction); + player.heldProj = projectile.whoAmI; + player.itemTime = 2; + player.itemAnimation = 2; + + // Multiplying by projectile.direction is required due to vanilla spaghetti. + player.itemRotation = (projectile.velocity * projectile.direction).ToRotation(); + } + + // Adjusts the aim vector of the staff to point towards the mouse. This is Last Prism code. + private void UpdateAim(Vector2 source, float speed) + { + Vector2 aimVector = Vector2.Normalize(Main.MouseWorld - source); + if (aimVector.HasNaNs()) + aimVector = -Vector2.UnitY; + aimVector = Vector2.Normalize(Vector2.Lerp(aimVector, Vector2.Normalize(projectile.velocity), AimResponsiveness)); + aimVector *= 30f; + + if (aimVector != projectile.velocity) + projectile.netUpdate = true; + projectile.velocity = aimVector; + } + + private void ChargingEffects(Vector2 center, float chargeLevel) + { + Lighting.AddLight(center, ValkyrieRay.LightColor.ToVector3() * chargeLevel); + + int numDust = 2; + int dustID = 73; + float incomingRadius = 9f; + for (int i = 0; i < numDust; ++i) + { + Vector2 offsetUnit = Main.rand.NextVector2Unit(); + Vector2 dustPos = center + offsetUnit * incomingRadius; + Dust d = Dust.NewDustDirect(dustPos, 0, 0, dustID, 0f, 0f); + d.velocity = offsetUnit * -Main.rand.NextFloat(2f, 3.5f); + d.scale = Main.rand.NextFloat(0.4f, 1f); + d.noGravity = true; + } + } + + private void FiringEffects(Vector2 center) + { + Main.PlaySound(SoundID.Item28, center); + Main.PlaySound(SoundID.Item60, center); + int numDust = 36; + int dustID = 73; + for (int i = 0; i < numDust; ++i) + { + Dust d = Dust.NewDustDirect(center, 0, 0, dustID, 0f, 0f); + d.velocity = (i * MathHelper.TwoPi / numDust).ToRotationVector2() * 2.2f; + d.scale = 1.4f; + d.noGravity = true; + } + } + } +} diff --git a/Projectiles/Magic/ValkyrieRayStaff.png b/Projectiles/Magic/ValkyrieRayStaff.png new file mode 100644 index 0000000000..18ec195aa0 Binary files /dev/null and b/Projectiles/Magic/ValkyrieRayStaff.png differ diff --git a/Projectiles/Magic/WaterStream.cs b/Projectiles/Magic/WaterStream.cs index 25067cab4d..9173858a11 100644 --- a/Projectiles/Magic/WaterStream.cs +++ b/Projectiles/Magic/WaterStream.cs @@ -5,8 +5,6 @@ namespace CalamityMod.Projectiles.Magic { public class WaterStream : ModProjectile { - public int addSprayTimer = 20; - public override void SetStaticDefaults() { DisplayName.SetDefault("Stream"); @@ -31,14 +29,12 @@ namespace CalamityMod.Projectiles.Magic { projectile.tileCollide = true; } - addSprayTimer--; - if (addSprayTimer <= 0) + if (projectile.timeLeft % 20 == 0) { if (projectile.owner == Main.myPlayer) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); } - addSprayTimer = 20; } Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.15f / 255f, (255 - projectile.alpha) * 0.25f / 255f); projectile.scale -= 0.002f; diff --git a/Projectiles/Magic/WaterStream2.cs b/Projectiles/Magic/WaterStream2.cs index 4c5e5e9d2b..0e58e022fe 100644 --- a/Projectiles/Magic/WaterStream2.cs +++ b/Projectiles/Magic/WaterStream2.cs @@ -41,22 +41,20 @@ namespace CalamityMod.Projectiles.Magic float num152 = projectile.velocity.X / 3f * (float)num151; float num153 = projectile.velocity.Y / 3f * (float)num151; int num154 = 14; - int num155 = Dust.NewDust(new Vector2(projectile.position.X + (float)num154, projectile.position.Y + (float)num154), projectile.width - num154 * 2, projectile.height - num154 * 2, 33, 0f, 0f, 100, default, 1f); - Main.dust[num155].noGravity = true; - Main.dust[num155].velocity *= 0.1f; - Main.dust[num155].velocity += projectile.velocity * 0.5f; - Dust expr_6A04_cp_0 = Main.dust[num155]; - expr_6A04_cp_0.position.X -= num152; - Dust expr_6A1F_cp_0 = Main.dust[num155]; - expr_6A1F_cp_0.position.Y -= num153; + int num155 = Dust.NewDust(new Vector2(projectile.position.X + (float)num154, projectile.position.Y + (float)num154), projectile.width - num154 * 2, projectile.height - num154 * 2, 14, 0f, 0f, 100, new Color(0, 255, 255), 1f); + Dust dust = Main.dust[num155]; + dust.noGravity = true; + dust.velocity *= 0.1f; + dust.velocity += projectile.velocity * 0.5f; + dust.position.X -= num152; + dust.position.Y -= num153; } if (Main.rand.NextBool(8)) { int num156 = 16; - int num157 = Dust.NewDust(new Vector2(projectile.position.X + (float)num156, projectile.position.Y + (float)num156), projectile.width - num156 * 2, projectile.height - num156 * 2, 33, 0f, 0f, 100, default, 0.5f); + int num157 = Dust.NewDust(new Vector2(projectile.position.X + (float)num156, projectile.position.Y + (float)num156), projectile.width - num156 * 2, projectile.height - num156 * 2, 14, 0f, 0f, 100, new Color(0, 255, 255), 0.5f); Main.dust[num157].velocity *= 0.25f; Main.dust[num157].velocity += projectile.velocity * 0.5f; - return; } } } diff --git a/Projectiles/Magic/YharimsCrystalPrism.cs b/Projectiles/Magic/YharimsCrystalPrism.cs index 4130582c2b..e578bb4856 100644 --- a/Projectiles/Magic/YharimsCrystalPrism.cs +++ b/Projectiles/Magic/YharimsCrystalPrism.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -43,7 +42,7 @@ namespace CalamityMod.Projectiles.Magic Vector2 rrp = player.RotatedRelativePoint(player.MountedCenter, true); // Update damage based on curent magic damage stat (so Mana Sickness affects it) - projectile.damage = (int)((player.HeldItem?.damage ?? 0) * player.MagicDamage()); + projectile.damage = (int)((player.ActiveItem()?.damage ?? 0) * player.MagicDamage()); // ai[0] is the overall frame counter. projectile.ai[0] += 1f; @@ -78,11 +77,11 @@ namespace CalamityMod.Projectiles.Magic if (projectile.owner == Main.myPlayer) { // Scale seemingly never changes, so this just scales with shoot speed (Yharim's Crystal is 30 by default) - float speedTimesScale = player.inventory[player.selectedItem].shootSpeed * projectile.scale; + float speedTimesScale = player.ActiveItem().shootSpeed * projectile.scale; UpdateAim(rrp, speedTimesScale); // CheckMana returns true if the mana cost can be paid. If mana isn't consumed this frame, the CheckMana short-circuits out of being evaluated. - bool allowContinuedUse = !ShouldConsumeMana() || player.CheckMana(player.inventory[player.selectedItem].mana, true, false); + bool allowContinuedUse = !ShouldConsumeMana() || player.CheckMana(player.ActiveItem().mana, true, false); bool crystalStillInUse = player.channel && allowContinuedUse && !player.noItems && !player.CCed; // The beams are only projected once (on frame 1). @@ -150,7 +149,9 @@ namespace CalamityMod.Projectiles.Magic player.heldProj = projectile.whoAmI; player.itemTime = 2; player.itemAnimation = 2; - player.itemRotation = (float)Math.Atan2(projectile.velocity.Y * projectile.direction, projectile.velocity.X * projectile.direction); + + // Multiplying by projectile.direction is required due to vanilla spaghetti. + player.itemRotation = (projectile.velocity * projectile.direction).ToRotation(); } private void SpawnEjectionDust(float charge) diff --git a/Projectiles/Melee/AstralScytheProjectile.cs b/Projectiles/Melee/AstralScytheProjectile.cs index 334ec4205f..01f07ca2dc 100644 --- a/Projectiles/Melee/AstralScytheProjectile.cs +++ b/Projectiles/Melee/AstralScytheProjectile.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 300; projectile.penetrate = 8; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 5; + projectile.localNPCHitCooldown = 7; projectile.tileCollide = false; } diff --git a/Projectiles/Melee/Brimblast.cs b/Projectiles/Melee/Brimblast.cs index 223e206483..a6c73f0f7b 100644 --- a/Projectiles/Melee/Brimblast.cs +++ b/Projectiles/Melee/Brimblast.cs @@ -53,26 +53,23 @@ namespace CalamityMod.Projectiles.Melee } projectile.rotation += projectile.velocity.X * 0.1f; int num199 = Dust.NewDust(projectile.position, projectile.width, projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); - Dust expr_8976_cp_0 = Main.dust[num199]; - expr_8976_cp_0.position.X -= 2f; - Dust expr_8994_cp_0 = Main.dust[num199]; - expr_8994_cp_0.position.Y += 2f; - Main.dust[num199].scale += (float)Main.rand.Next(50) * 0.01f; - Main.dust[num199].noGravity = true; - Dust expr_89E7_cp_0 = Main.dust[num199]; - expr_89E7_cp_0.velocity.Y -= 4f; + Dust dust = Main.dust[num199]; + dust.position.X -= 2f; + dust.position.Y += 2f; + dust.scale += (float)Main.rand.Next(50) * 0.01f; + dust.noGravity = true; + dust.velocity.Y -= 4f; if (Main.rand.NextBool(2)) { int num200 = Dust.NewDust(projectile.position, projectile.width, projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); - Dust expr_8A4E_cp_0 = Main.dust[num200]; - expr_8A4E_cp_0.position.X -= 2f; - Dust expr_8A6C_cp_0 = Main.dust[num200]; - expr_8A6C_cp_0.position.Y += 2f; - Main.dust[num200].scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; - Main.dust[num200].noGravity = true; - Main.dust[num200].velocity *= 0.2f; + Dust dust2 = Main.dust[num200]; + dust2.position.X -= 2f; + dust2.position.Y += 2f; + dust2.scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; + dust2.noGravity = true; + dust2.velocity *= 0.2f; } - if ((double)projectile.velocity.Y < 0.25 && (double)projectile.velocity.Y > 0.15) + if (projectile.velocity.Y < 0.25f && projectile.velocity.Y > 0.15f) { projectile.velocity.X = projectile.velocity.X * 0.8f; } diff --git a/Projectiles/Melee/BrimstoneSwordExplosion.cs b/Projectiles/Melee/BrimstoneSwordExplosion.cs index 5d99bf64c6..01105d1fc3 100644 --- a/Projectiles/Melee/BrimstoneSwordExplosion.cs +++ b/Projectiles/Melee/BrimstoneSwordExplosion.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Projectiles.Melee projectile.friendly = true; projectile.ignoreWater = true; projectile.tileCollide = false; - projectile.penetrate = -1; + projectile.penetrate = 3; projectile.timeLeft = 60; projectile.melee = true; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Melee/DevilsSunriseProj.cs b/Projectiles/Melee/DevilsSunriseProj.cs index 402a915562..db87deba3c 100644 --- a/Projectiles/Melee/DevilsSunriseProj.cs +++ b/Projectiles/Melee/DevilsSunriseProj.cs @@ -67,8 +67,8 @@ namespace CalamityMod.Projectiles.Melee { float scaleFactor6 = 1f; - if (player.inventory[player.selectedItem].shoot == projectile.type) - scaleFactor6 = player.inventory[player.selectedItem].shootSpeed * projectile.scale; + if (player.ActiveItem().shoot == projectile.type) + scaleFactor6 = player.ActiveItem().shootSpeed * projectile.scale; Vector2 vector13 = Main.MouseWorld - vector; vector13.Normalize(); diff --git a/Projectiles/Melee/Earth4.cs b/Projectiles/Melee/Earth4.cs index 4be8960038..75586af9c4 100644 --- a/Projectiles/Melee/Earth4.cs +++ b/Projectiles/Melee/Earth4.cs @@ -95,8 +95,8 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 4); - float num = (float)damage * 0.075f; - if ((int)num == 0) + float healAmt = (float)damage * 0.075f; + if ((int)healAmt == 0) { return; } @@ -104,9 +104,7 @@ namespace CalamityMod.Projectiles.Melee { return; } - Main.player[Main.myPlayer].lifeSteal -= num * 1.5f; - int num2 = projectile.owner; - Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, projectile.owner, (float)num2, num); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 1.5f); } } } diff --git a/Projectiles/Melee/EssenceScythe.cs b/Projectiles/Melee/EssenceScythe.cs index 3a0999fd64..d863436f56 100644 --- a/Projectiles/Melee/EssenceScythe.cs +++ b/Projectiles/Melee/EssenceScythe.cs @@ -80,7 +80,7 @@ namespace CalamityMod.Projectiles.Melee { if (projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f, ModContent.ProjectileType(), 0, 0, projectile.owner, 0f, 0f); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], 8, ModContent.ProjectileType(), 1200f, 0f); } } } diff --git a/Projectiles/Melee/Exocomet.cs b/Projectiles/Melee/Exocomet.cs index 77f949596a..6cbfc7d942 100644 --- a/Projectiles/Melee/Exocomet.cs +++ b/Projectiles/Melee/Exocomet.cs @@ -103,8 +103,8 @@ namespace CalamityMod.Projectiles.Melee { return; } - float num = (float)damage * 0.01f; - if ((int)num == 0) + float healAmt = (float)damage * 0.01f; + if ((int)healAmt == 0) { return; } @@ -112,9 +112,7 @@ namespace CalamityMod.Projectiles.Melee { return; } - Main.player[Main.myPlayer].lifeSteal -= num; - int num2 = projectile.owner; - Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, projectile.owner, (float)num2, num); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 1f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/ForbiddenOathbladeProjectile.cs b/Projectiles/Melee/ForbiddenOathbladeProjectile.cs new file mode 100644 index 0000000000..9e418aff11 --- /dev/null +++ b/Projectiles/Melee/ForbiddenOathbladeProjectile.cs @@ -0,0 +1,53 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class ForbiddenOathbladeProjectile : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Oathblade"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } + + public override void SetDefaults() + { + projectile.width = 50; + projectile.height = 50; + projectile.aiStyle = 18; + projectile.alpha = 100; + projectile.friendly = true; + projectile.melee = true; + projectile.tileCollide = true; + projectile.penetrate = 3; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 30; + aiType = ProjectileID.DemonScythe; + } + + public override void AI() + { + Lighting.AddLight(projectile.Center, 0.35f, 0f, 0.35f); + + if (Main.rand.NextBool(3)) + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 173, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.OnFire, 180); + target.AddBuff(BuffID.ShadowFlame, 180); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 2); + return false; + } + } +} diff --git a/Projectiles/Melee/ForbiddenOathbladeProjectile.png b/Projectiles/Melee/ForbiddenOathbladeProjectile.png new file mode 100644 index 0000000000..e594d983b1 Binary files /dev/null and b/Projectiles/Melee/ForbiddenOathbladeProjectile.png differ diff --git a/Projectiles/Melee/MurasamaProj.cs b/Projectiles/Melee/MurasamaProj.cs index 4cfecc40cb..625d47d292 100644 --- a/Projectiles/Melee/MurasamaProj.cs +++ b/Projectiles/Melee/MurasamaProj.cs @@ -53,9 +53,9 @@ namespace CalamityMod.Projectiles.Melee if (player.channel && !player.noItems && !player.CCed) { float scaleFactor6 = 1f; - if (player.inventory[player.selectedItem].shoot == projectile.type) + if (player.ActiveItem().shoot == projectile.type) { - scaleFactor6 = player.inventory[player.selectedItem].shootSpeed * projectile.scale; + scaleFactor6 = player.ActiveItem().shootSpeed * projectile.scale; } Vector2 vector13 = Main.MouseWorld - vector; vector13.Normalize(); diff --git a/Projectiles/Melee/NebulashFlail.cs b/Projectiles/Melee/NebulashFlail.cs index 47cba7fb60..4e889530fc 100644 --- a/Projectiles/Melee/NebulashFlail.cs +++ b/Projectiles/Melee/NebulashFlail.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; projectile.ignoreWater = true; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 2; + projectile.localNPCHitCooldown = 3; } public override Color SpecialDrawColor => new Color(255, 200, 0); public override int ExudeDustType => ModContent.DustType(); @@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Melee target.AddBuff(ModContent.BuffType(), 120); if (projectile.localAI[1] <= 0f && projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, knockback, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage / 2, knockback, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); } projectile.localAI[1] = 4f; } diff --git a/Projectiles/Melee/Oathblade.cs b/Projectiles/Melee/Oathblade.cs index 95bf1d44e0..416d3324ae 100644 --- a/Projectiles/Melee/Oathblade.cs +++ b/Projectiles/Melee/Oathblade.cs @@ -24,22 +24,20 @@ namespace CalamityMod.Projectiles.Melee projectile.friendly = true; projectile.melee = true; projectile.tileCollide = true; - projectile.penetrate = 3; + projectile.penetrate = 1; aiType = ProjectileID.DemonScythe; } public override void AI() { Lighting.AddLight(projectile.Center, 0.35f, 0f, 0.35f); + if (Main.rand.NextBool(3)) - { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 173, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f); - } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.immune[projectile.owner] = 10; target.AddBuff(BuffID.OnFire, 180); target.AddBuff(BuffID.ShadowFlame, 180); } diff --git a/Projectiles/Melee/ProfanedSwordProj.cs b/Projectiles/Melee/ProfanedSwordProj.cs index 05009bac76..c1cf5da794 100644 --- a/Projectiles/Melee/ProfanedSwordProj.cs +++ b/Projectiles/Melee/ProfanedSwordProj.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Projectiles.Melee { public class ProfanedSwordProj : ModProjectile { + private int explosionCount = 0; public override void SetStaticDefaults() { DisplayName.SetDefault("Profaned Sword"); @@ -65,8 +66,16 @@ namespace CalamityMod.Projectiles.Melee target.AddBuff(ModContent.BuffType(), 180); if (Main.myPlayer == projectile.owner) { - Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), knockback, projectile.owner); + if (explosionCount < 3) + { + Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), knockback, projectile.owner); + explosionCount++; + } } + if (projectile.damage > 1) + projectile.damage = (int)(projectile.damage * 0.6); + if (projectile.damage <= 0) + projectile.damage = 1; } } } diff --git a/Projectiles/Melee/RoyalKnifeMelee.cs b/Projectiles/Melee/RoyalKnifeMelee.cs deleted file mode 100644 index 6b0648ec3b..0000000000 --- a/Projectiles/Melee/RoyalKnifeMelee.cs +++ /dev/null @@ -1,95 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Projectiles.Healing; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Melee -{ - public class RoyalKnifeMelee : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Knife"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } - - public override void SetDefaults() - { - projectile.width = 18; - projectile.height = 18; - projectile.friendly = true; - projectile.penetrate = 1; - projectile.timeLeft = 300; - projectile.melee = true; - } - - public override void AI() - { - projectile.ai[0] += 1f; - if (projectile.ai[0] >= 240f) - { - projectile.alpha += 4; - projectile.damage = (int)((double)projectile.damage * 0.95); - projectile.knockBack = (float)(int)((double)projectile.knockBack * 0.95); - } - - if (projectile.ai[0] < 240f) - { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; - } - else - { - projectile.rotation += 0.5f; - } - - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 800f, 35f, 20f); - - if (Main.rand.NextBool(6)) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 20, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - } - } - - public override void Kill(int timeLeft) - { - for (int num303 = 0; num303 < 3; num303++) - { - int num304 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 20, 0f, 0f, 100, default, 0.8f); - Main.dust[num304].noGravity = true; - Main.dust[num304].velocity *= 1.2f; - Main.dust[num304].velocity -= projectile.oldVelocity * 0.3f; - } - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 600); - if (target.type == NPCID.TargetDummy) - { - return; - } - float num = (float)damage * 0.015f; - if ((int)num == 0) - { - return; - } - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - { - return; - } - Main.player[Main.myPlayer].lifeSteal -= num * 1.5f; - int num2 = projectile.owner; - Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, projectile.owner, (float)num2, num); - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); - return false; - } - } -} diff --git a/Projectiles/Melee/RoyalKnifeMelee.png b/Projectiles/Melee/RoyalKnifeMelee.png deleted file mode 100644 index d8793dd624..0000000000 Binary files a/Projectiles/Melee/RoyalKnifeMelee.png and /dev/null differ diff --git a/Projectiles/Melee/Spears/DiseasedPikeSpear.cs b/Projectiles/Melee/Spears/DiseasedPikeSpear.cs index 0dad8c1115..af0042f9e7 100644 --- a/Projectiles/Melee/Spears/DiseasedPikeSpear.cs +++ b/Projectiles/Melee/Spears/DiseasedPikeSpear.cs @@ -38,13 +38,13 @@ namespace CalamityMod.Projectiles.Melee.Spears public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.immune[projectile.owner] = 6; + target.immune[projectile.owner] = 7; target.AddBuff(ModContent.BuffType(), 360); if (projectile.owner == Main.myPlayer) { for (int i = 0; i < 4; i++) { - Projectile.NewProjectile(projectile.Center, projectile.velocity * 1.5f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, projectile.velocity * 1.5f, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Melee/TemporalFloeNumberTwo.cs b/Projectiles/Melee/TemporalFloeNumberTwo.cs new file mode 100644 index 0000000000..08a0926a8c --- /dev/null +++ b/Projectiles/Melee/TemporalFloeNumberTwo.cs @@ -0,0 +1,79 @@ +using CalamityMod.Buffs.StatDebuffs; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Melee +{ + public class TemporalFloeNumberTwo : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/Melee/TemporalFloeSwordProjectile"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Floe"); + } + + public override void SetDefaults() + { + projectile.width = 20; + projectile.height = 20; + projectile.aiStyle = 27; + projectile.friendly = true; + projectile.melee = true; + projectile.penetrate = -1; + projectile.timeLeft = 60; + projectile.coldDamage = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.tileCollide = false; + } + + public override void AI() + { + Lighting.AddLight(projectile.Center, 0f, (255 - projectile.alpha) * 0.05f / 255f, (255 - projectile.alpha) * 0.35f / 255f); + if (Main.rand.NextBool(2)) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 56, 0f, 0f); + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D tex = Main.projectileTexture[projectile.type]; + spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); + return false; + } + + public override Color? GetAlpha(Color lightColor) + { + return new Color(50, 50, 255, projectile.alpha); + } + + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item10, projectile.position); + for (int num795 = 0; num795 < 27; num795++) + { + float num796 = projectile.oldVelocity.X * (30f / (float)num795); + float num797 = projectile.oldVelocity.Y * (30f / (float)num795); + int num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, 56, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.8f); + Dust dust = Main.dust[num798]; + dust.noGravity = true; + dust.velocity *= 0.5f; + num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, 56, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.4f); + dust.velocity *= 0.05f; + } + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (Main.rand.NextBool(3)) + { + target.AddBuff(ModContent.BuffType(), 120); + } + target.AddBuff(BuffID.Frostburn, 240); + } + } +} diff --git a/Projectiles/Melee/TemporalFloeSwordProjectile.cs b/Projectiles/Melee/TemporalFloeSwordProjectile.cs index 8a88e757d3..7c2997f2e3 100644 --- a/Projectiles/Melee/TemporalFloeSwordProjectile.cs +++ b/Projectiles/Melee/TemporalFloeSwordProjectile.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -52,17 +53,53 @@ namespace CalamityMod.Projectiles.Melee public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item10, projectile.position); - for (int num795 = 0; num795 < 27; num795++) - { - float num796 = projectile.oldVelocity.X * (30f / (float)num795); - float num797 = projectile.oldVelocity.Y * (30f / (float)num795); - int num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, 56, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.8f); - Dust dust = Main.dust[num798]; - dust.noGravity = true; - dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, 56, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.4f); - dust.velocity *= 0.05f; - } + + // Get Terraria's current strange time variable + double time = Main.time; + + // Correct for night time (which for some reason isn't just a different number) by adding 54000. + if (!Main.dayTime) + time += 54000D; + + // Divide by seconds in an hour + time /= 3600D; + + // Terraria night starts at 7:30 PM, so offset accordingly + time -= 19.5; + + // Offset time to ensure it is not negative + if (time < 0D) + time += 24D; + + // Get the decimal (smaller than hours, so minutes) component of time. + int intTime = (int)time; + double deltaTime = time - intTime; + + // Convert decimal time into an exact number of minutes. + deltaTime = (int)(deltaTime * 60D); + + // Convert from 24 to 12 hour time + if (intTime > 12) + intTime -= 12; + + float projSpeed = 8f; + + float hour = (float)intTime; + float hourAngle = MathHelper.PiOver2 - (MathHelper.TwoPi / 12f) * hour; + hourAngle *= -1f; //correction because lol + Vector2 hourVector = hourAngle.ToRotationVector2() * projSpeed; + + float minute = (float)deltaTime; + float minuteAngle = MathHelper.PiOver2 - (MathHelper.TwoPi / 60f) * minute; + minuteAngle *= -1f; //correction because pain + Vector2 minuteVector = minuteAngle.ToRotationVector2() * projSpeed; + + int projType = ModContent.ProjectileType(); + int dmg = projectile.damage / 2; + float kback = projectile.knockBack * 0.5f; + + Projectile.NewProjectile(projectile.Center, hourVector, projType, dmg, kback, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, minuteVector, projType, dmg, kback, projectile.owner, 0f, 0f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Pets/Sparks.cs b/Projectiles/Pets/Sparks.cs index 9f0e658007..452b26e55e 100644 --- a/Projectiles/Pets/Sparks.cs +++ b/Projectiles/Pets/Sparks.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Pets if (new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height).Intersects(new Rectangle((int)item.position.X, (int)item.position.Y, item.width, item.height))) { - if (projectile.owner == Main.myPlayer && (player.inventory[player.selectedItem].type != 0 || player.itemAnimation <= 0)) + if (projectile.owner == Main.myPlayer && (player.ActiveItem().type != 0 || player.itemAnimation <= 0)) { // TODO, fix this maybe? if (!ItemLoader.OnPickup(item, player)) diff --git a/Projectiles/Ranged/ButcherGun.cs b/Projectiles/Ranged/ButcherGun.cs index 81eb1119c6..f5e40a58fb 100644 --- a/Projectiles/Ranged/ButcherGun.cs +++ b/Projectiles/Ranged/ButcherGun.cs @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.ai[1] = (float)(num40 - num41 * num39); flag15 = true; } - bool flag16 = player.channel && player.HasAmmo(player.inventory[player.selectedItem], true) && !player.noItems && !player.CCed; + bool flag16 = player.channel && player.HasAmmo(player.ActiveItem(), true) && !player.noItems && !player.CCed; if (projectile.localAI[0] > 0f) { projectile.localAI[0] -= 1f; @@ -103,13 +103,13 @@ namespace CalamityMod.Projectiles.Ranged { int num42 = 14; float scaleFactor11 = 14f; - int weaponDamage2 = player.GetWeaponDamage(player.inventory[player.selectedItem]); - float weaponKnockback2 = player.inventory[player.selectedItem].knockBack; + int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); + float weaponKnockback2 = player.ActiveItem().knockBack; if (flag16) { - player.PickAmmo(player.inventory[player.selectedItem], ref num42, ref scaleFactor11, ref flag16, ref weaponDamage2, ref weaponKnockback2, false); - weaponKnockback2 = player.GetWeaponKnockback(player.inventory[player.selectedItem], weaponKnockback2); - float scaleFactor12 = player.inventory[player.selectedItem].shootSpeed * projectile.scale; + player.PickAmmo(player.ActiveItem(), ref num42, ref scaleFactor11, ref flag16, ref weaponDamage2, ref weaponKnockback2, false); + weaponKnockback2 = player.GetWeaponKnockback(player.ActiveItem(), weaponKnockback2); + float scaleFactor12 = player.ActiveItem().shootSpeed * projectile.scale; Vector2 vector19 = vector; Vector2 value18 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - vector19; if (player.gravDir == -1f) diff --git a/Projectiles/Ranged/ContagionBow.cs b/Projectiles/Ranged/ContagionBow.cs index 1e49a6b92f..96483efc4a 100644 --- a/Projectiles/Ranged/ContagionBow.cs +++ b/Projectiles/Ranged/ContagionBow.cs @@ -85,10 +85,10 @@ namespace CalamityMod.Projectiles.Ranged } if (flag && Main.myPlayer == projectile.owner) { - bool flag2 = player.channel && player.CheckMana(player.inventory[player.selectedItem].mana, true, false) && !player.noItems && !player.CCed; + bool flag2 = player.channel && player.CheckMana(player.ActiveItem().mana, true, false) && !player.noItems && !player.CCed; if (flag2) { - float scaleFactor = player.inventory[player.selectedItem].shootSpeed * projectile.scale; + float scaleFactor = player.ActiveItem().shootSpeed * projectile.scale; Vector2 value2 = vector; Vector2 value3 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - value2; if (player.gravDir == -1f) diff --git a/Projectiles/Ranged/DaemonsFlameBow.cs b/Projectiles/Ranged/DaemonsFlameBow.cs index e86672be02..a4d3999efa 100644 --- a/Projectiles/Ranged/DaemonsFlameBow.cs +++ b/Projectiles/Ranged/DaemonsFlameBow.cs @@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.Ranged flag15 = true; int arg_1EF4_0 = (int)projectile.ai[0] / (num40 - num41 * num39); } - bool flag16 = player.channel && player.HasAmmo(player.inventory[player.selectedItem], true) && !player.noItems && !player.CCed; + bool flag16 = player.channel && player.HasAmmo(player.ActiveItem(), true) && !player.noItems && !player.CCed; if (projectile.localAI[0] > 0f) { projectile.localAI[0] -= 1f; @@ -92,13 +92,13 @@ namespace CalamityMod.Projectiles.Ranged { int num42 = 14; float scaleFactor11 = 14f; - int weaponDamage2 = player.GetWeaponDamage(player.inventory[player.selectedItem]); - float weaponKnockback2 = player.inventory[player.selectedItem].knockBack; + int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); + float weaponKnockback2 = player.ActiveItem().knockBack; if (flag16) { - player.PickAmmo(player.inventory[player.selectedItem], ref num42, ref scaleFactor11, ref flag16, ref weaponDamage2, ref weaponKnockback2, false); - weaponKnockback2 = player.GetWeaponKnockback(player.inventory[player.selectedItem], weaponKnockback2); - float scaleFactor12 = player.inventory[player.selectedItem].shootSpeed * projectile.scale; + player.PickAmmo(player.ActiveItem(), ref num42, ref scaleFactor11, ref flag16, ref weaponDamage2, ref weaponKnockback2, false); + weaponKnockback2 = player.GetWeaponKnockback(player.ActiveItem(), weaponKnockback2); + float scaleFactor12 = player.ActiveItem().shootSpeed * projectile.scale; Vector2 vector19 = vector; Vector2 value18 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - vector19; if (player.gravDir == -1f) diff --git a/Projectiles/Ranged/DrataliornusBow.cs b/Projectiles/Ranged/DrataliornusBow.cs index d454833f74..8a317572fa 100644 --- a/Projectiles/Ranged/DrataliornusBow.cs +++ b/Projectiles/Ranged/DrataliornusBow.cs @@ -76,7 +76,7 @@ namespace CalamityMod.Projectiles.Ranged timeToFire = true; } - bool canFire = player.channel && player.HasAmmo(player.inventory[player.selectedItem], true) && !player.noItems && !player.CCed; + bool canFire = player.channel && player.HasAmmo(player.ActiveItem(), true) && !player.noItems && !player.CCed; if (projectile.soundDelay <= 0 && canFire) { @@ -91,13 +91,13 @@ namespace CalamityMod.Projectiles.Ranged { int type = 14; float scaleFactor = 18f; - int damage = player.GetWeaponDamage(player.inventory[player.selectedItem]); - float knockBack = player.inventory[player.selectedItem].knockBack; + int damage = player.GetWeaponDamage(player.ActiveItem()); + float knockBack = player.ActiveItem().knockBack; - player.PickAmmo(player.inventory[player.selectedItem], ref type, ref scaleFactor, ref canFire, ref damage, ref knockBack, false); + player.PickAmmo(player.ActiveItem(), ref type, ref scaleFactor, ref canFire, ref damage, ref knockBack, false); type = ModContent.ProjectileType(); - knockBack = player.GetWeaponKnockback(player.inventory[player.selectedItem], knockBack); + knockBack = player.GetWeaponKnockback(player.ActiveItem(), knockBack); Vector2 playerPosition = player.RotatedRelativePoint(player.MountedCenter, true); projectile.velocity = Main.screenPosition - playerPosition; diff --git a/Projectiles/Ranged/FlakKrakenGun.cs b/Projectiles/Ranged/FlakKrakenGun.cs index 5571b2b96a..3b338314f4 100644 --- a/Projectiles/Ranged/FlakKrakenGun.cs +++ b/Projectiles/Ranged/FlakKrakenGun.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Ranged { num26 = 5f; } - projectile.damage = (int)(player.inventory[player.selectedItem].damage * player.RangedDamage()); + projectile.damage = (int)(player.ActiveItem().damage * player.RangedDamage()); projectile.ai[0] += 1f; projectile.ai[1] += 1f; int num27 = 10; @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Ranged flag10 = true; if (Main.myPlayer == projectile.owner) { - float scaleFactor5 = player.inventory[player.selectedItem].shootSpeed * projectile.scale; + float scaleFactor5 = player.ActiveItem().shootSpeed * projectile.scale; Vector2 value12 = vector; Vector2 value13 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - value12; if (player.gravDir == -1f) diff --git a/Projectiles/Ranged/FlurrystormCannonShooting.cs b/Projectiles/Ranged/FlurrystormCannonShooting.cs index 2d92db8535..286986f8e6 100644 --- a/Projectiles/Ranged/FlurrystormCannonShooting.cs +++ b/Projectiles/Ranged/FlurrystormCannonShooting.cs @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.ai[1] = (float)(num40 - num41 * num39); flag15 = true; } - bool flag16 = player.channel && player.HasAmmo(player.inventory[player.selectedItem], true) && !player.noItems && !player.CCed; + bool flag16 = player.channel && player.HasAmmo(player.ActiveItem(), true) && !player.noItems && !player.CCed; if (projectile.localAI[0] > 0f) { projectile.localAI[0] -= 1f; @@ -107,13 +107,13 @@ namespace CalamityMod.Projectiles.Ranged { int num42 = 14; float scaleFactor11 = 14f; - int weaponDamage2 = player.GetWeaponDamage(player.inventory[player.selectedItem]); - float weaponKnockback2 = player.inventory[player.selectedItem].knockBack; + int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); + float weaponKnockback2 = player.ActiveItem().knockBack; if (flag16) { - player.PickAmmo(player.inventory[player.selectedItem], ref num42, ref scaleFactor11, ref flag16, ref weaponDamage2, ref weaponKnockback2, false); - weaponKnockback2 = player.GetWeaponKnockback(player.inventory[player.selectedItem], weaponKnockback2); - float scaleFactor12 = player.inventory[player.selectedItem].shootSpeed * projectile.scale; + player.PickAmmo(player.ActiveItem(), ref num42, ref scaleFactor11, ref flag16, ref weaponDamage2, ref weaponKnockback2, false); + weaponKnockback2 = player.GetWeaponKnockback(player.ActiveItem(), weaponKnockback2); + float scaleFactor12 = player.ActiveItem().shootSpeed * projectile.scale; Vector2 vector19 = vector; Vector2 value18 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - vector19; if (player.gravDir == -1f) diff --git a/Projectiles/Ranged/MechanicalBarracuda.cs b/Projectiles/Ranged/MechanicalBarracuda.cs index 39d87dcbf0..e57ef9f6f0 100644 --- a/Projectiles/Ranged/MechanicalBarracuda.cs +++ b/Projectiles/Ranged/MechanicalBarracuda.cs @@ -1,4 +1,5 @@ using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { @@ -16,7 +17,6 @@ namespace CalamityMod.Projectiles.Ranged projectile.height = 22; projectile.friendly = true; projectile.aiStyle = 39; - aiType = 190; projectile.penetrate = -1; projectile.alpha = 255; projectile.ranged = true; diff --git a/Projectiles/Ranged/NorfleetCannon.cs b/Projectiles/Ranged/NorfleetCannon.cs index ec74639dfd..d28ceb5ce7 100644 --- a/Projectiles/Ranged/NorfleetCannon.cs +++ b/Projectiles/Ranged/NorfleetCannon.cs @@ -65,7 +65,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.ai[1] = baseUseTime - modifier * projectile.localAI[0]; timeToFire = true; } - bool canFire = player.channel && player.HasAmmo(player.inventory[player.selectedItem], true) && !player.noItems && !player.CCed; + bool canFire = player.channel && player.HasAmmo(player.ActiveItem(), true) && !player.noItems && !player.CCed; if (projectile.soundDelay <= 0 && canFire) { projectile.soundDelay = baseUseTime - modifier * (int)projectile.localAI[0]; @@ -79,12 +79,12 @@ namespace CalamityMod.Projectiles.Ranged { int type = 12; float scaleFactor = 30f; - int damage = player.GetWeaponDamage(player.inventory[player.selectedItem]); - float knockBack = player.inventory[player.selectedItem].knockBack; + int damage = player.GetWeaponDamage(player.ActiveItem()); + float knockBack = player.ActiveItem().knockBack; for (int i = 0; i < 5; i++) { - player.PickAmmo(player.inventory[player.selectedItem], ref type, ref scaleFactor, ref canFire, ref damage, ref knockBack, false); - knockBack = player.GetWeaponKnockback(player.inventory[player.selectedItem], knockBack); + player.PickAmmo(player.ActiveItem(), ref type, ref scaleFactor, ref canFire, ref damage, ref knockBack, false); + knockBack = player.GetWeaponKnockback(player.ActiveItem(), knockBack); Vector2 playerPosition = player.RotatedRelativePoint(player.MountedCenter, true); projectile.velocity = Main.screenPosition - playerPosition; projectile.velocity.X += Main.mouseX; diff --git a/Projectiles/Ranged/PhangasmBow.cs b/Projectiles/Ranged/PhangasmBow.cs index ba5aadfb48..cd85a5abc1 100644 --- a/Projectiles/Ranged/PhangasmBow.cs +++ b/Projectiles/Ranged/PhangasmBow.cs @@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Ranged flag15 = true; int arg_1EF4_0 = (int)projectile.ai[0] / (num40 - num41 * num39); } - bool flag16 = player.channel && player.HasAmmo(player.inventory[player.selectedItem], true) && !player.noItems && !player.CCed; + bool flag16 = player.channel && player.HasAmmo(player.ActiveItem(), true) && !player.noItems && !player.CCed; if (projectile.localAI[0] > 0f) { projectile.localAI[0] -= 1f; @@ -77,13 +77,13 @@ namespace CalamityMod.Projectiles.Ranged { int num42 = 14; float scaleFactor11 = 14f; - int weaponDamage2 = player.GetWeaponDamage(player.inventory[player.selectedItem]); - float weaponKnockback2 = player.inventory[player.selectedItem].knockBack; + int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); + float weaponKnockback2 = player.ActiveItem().knockBack; if (flag16) { - player.PickAmmo(player.inventory[player.selectedItem], ref num42, ref scaleFactor11, ref flag16, ref weaponDamage2, ref weaponKnockback2, false); - weaponKnockback2 = player.GetWeaponKnockback(player.inventory[player.selectedItem], weaponKnockback2); - float scaleFactor12 = player.inventory[player.selectedItem].shootSpeed * projectile.scale; + player.PickAmmo(player.ActiveItem(), ref num42, ref scaleFactor11, ref flag16, ref weaponDamage2, ref weaponKnockback2, false); + weaponKnockback2 = player.GetWeaponKnockback(player.ActiveItem(), weaponKnockback2); + float scaleFactor12 = player.ActiveItem().shootSpeed * projectile.scale; Vector2 vector19 = vector; Vector2 value18 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - vector19; if (player.gravDir == -1f) diff --git a/Projectiles/Ranged/ShockblastRound.cs b/Projectiles/Ranged/ShockblastRound.cs index af488c6eb4..fd7f0cefa0 100644 --- a/Projectiles/Ranged/ShockblastRound.cs +++ b/Projectiles/Ranged/ShockblastRound.cs @@ -90,8 +90,8 @@ namespace CalamityMod.Projectiles.Ranged { return; } - float num = (float)damage * 0.05f; - if ((int)num == 0) + float healAmt = (float)damage * 0.05f; + if ((int)healAmt == 0) { return; } @@ -99,9 +99,7 @@ namespace CalamityMod.Projectiles.Ranged { return; } - Main.player[Main.myPlayer].lifeSteal -= num * 1.5f; - int num2 = projectile.owner; - Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, projectile.owner, (float)num2, num); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 1.5f); } } } diff --git a/Projectiles/Ranged/StarfleetMK2Gun.cs b/Projectiles/Ranged/StarfleetMK2Gun.cs index 4372a7928a..40b0bf1e3b 100644 --- a/Projectiles/Ranged/StarfleetMK2Gun.cs +++ b/Projectiles/Ranged/StarfleetMK2Gun.cs @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.ai[1] = baseUseTime - modifier * projectile.localAI[0]; timeToFire = true; } - bool canFire = player.channel && player.HasAmmo(player.inventory[player.selectedItem], true) && !player.noItems && !player.CCed; + bool canFire = player.channel && player.HasAmmo(player.ActiveItem(), true) && !player.noItems && !player.CCed; if (projectile.soundDelay <= 0 && canFire) { projectile.soundDelay = baseUseTime - modifier * (int)projectile.localAI[0]; @@ -82,12 +82,12 @@ namespace CalamityMod.Projectiles.Ranged { int type = ModContent.ProjectileType(); float scaleFactor = 16f; - int damage = player.GetWeaponDamage(player.inventory[player.selectedItem]); - float knockBack = player.inventory[player.selectedItem].knockBack; - player.PickAmmo(player.inventory[player.selectedItem], ref type, ref scaleFactor, ref canFire, ref damage, ref knockBack, false); + int damage = player.GetWeaponDamage(player.ActiveItem()); + float knockBack = player.ActiveItem().knockBack; + player.PickAmmo(player.ActiveItem(), ref type, ref scaleFactor, ref canFire, ref damage, ref knockBack, false); for (int i = 0; i < 5; i++) { - knockBack = player.GetWeaponKnockback(player.inventory[player.selectedItem], knockBack); + knockBack = player.GetWeaponKnockback(player.ActiveItem(), knockBack); Vector2 playerPosition = player.RotatedRelativePoint(player.MountedCenter, true); projectile.velocity = Main.screenPosition - playerPosition; projectile.velocity.X += Main.mouseX; diff --git a/Projectiles/Rogue/BrackishFlaskProj.cs b/Projectiles/Rogue/BrackishFlaskProj.cs index 261c882666..0864fc042e 100644 --- a/Projectiles/Rogue/BrackishFlaskProj.cs +++ b/Projectiles/Rogue/BrackishFlaskProj.cs @@ -51,8 +51,8 @@ namespace CalamityMod.Projectiles.Rogue for (i = 0; i < 4; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Rogue/EclipsesStealth.cs b/Projectiles/Rogue/EclipsesStealth.cs index 924dcfb246..4cfa10ab98 100644 --- a/Projectiles/Rogue/EclipsesStealth.cs +++ b/Projectiles/Rogue/EclipsesStealth.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Projectiles.Rogue { public class EclipsesStealth : ModProjectile { - private int deadinside = 0; //used to know when to drop spears from the sky + private bool changedTimeLeft = false; public override void SetStaticDefaults() { @@ -34,11 +34,9 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - deadinside++; //congrats Pinkie - if (deadinside >= 5) //every 5 ticks + if (projectile.timeLeft % 5 == 0) //congrats Pinkie... every 5 ticks { - deadinside = 0; - if (Main.rand.Next(2) == 0) + if (Main.rand.NextBool(2)) { int spearAmt = Main.rand.Next(1, 4); //1 to 3 spears for (int n = 0; n < spearAmt; n++) @@ -54,136 +52,30 @@ namespace CalamityMod.Projectiles.Rogue num16 = (float)num15 / num16; num13 *= num16; num14 *= num16; - Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.08 * Main.rand.Next(4, 7)), (int)((double)projectile.knockBack * 0.1 * Main.rand.Next(7, 10)), projectile.owner, 0f, 0f); + Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType(), (int)(projectile.damage * Main.rand.NextFloat(0.32f, 0.56f)), projectile.knockBack * Main.rand.NextFloat(0.32f, 0.56f), projectile.owner, 0f, 0f); } //very complicated and painful } } if (projectile.ai[0] == 0f) { projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f; - if (Main.rand.Next(8) == 0) //dust + if (Main.rand.NextBool(8)) //dust { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 138, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } } - if (projectile.ai[0] == 1f) //sticking to enemies - { - int num988 = 15; - bool flag54 = false; - bool flag55 = false; - projectile.localAI[0] += 1f; - if (projectile.localAI[0] % 30f == 0f) - { - flag55 = true; - } - int num989 = (int)projectile.ai[1]; - if (projectile.localAI[0] >= (float)(60 * num988)) - { - flag54 = true; - } - else if (num989 < 0 || num989 >= 200) - { - flag54 = true; - } - else if (Main.npc[num989].active && !Main.npc[num989].dontTakeDamage) - { - projectile.Center = Main.npc[num989].Center - projectile.velocity * 2f; - projectile.gfxOffY = Main.npc[num989].gfxOffY; - if (flag55) - { - Main.npc[num989].HitEffect(0, 1.0); - } - } - else - { - flag54 = true; - } - if (flag54) - { - projectile.Kill(); - } - } + if (projectile.ai[0] == 1f && !changedTimeLeft) + { + projectile.timeLeft = 900; + changedTimeLeft = true; + } + //Sticky Behaviour + CalamityUtils.StickyProjAI(projectile, 15); } - #region SpearBarrage - public void SpearBarrage(Player player) - { - } - #endregion - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - Rectangle myRect = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < 200; i++) - { - if (Main.npc[i].active && !Main.npc[i].dontTakeDamage && - ((projectile.friendly && (!Main.npc[i].friendly || projectile.type == 318 || (Main.npc[i].type == 22 && projectile.owner < 255 && Main.player[projectile.owner].killGuide) || (Main.npc[i].type == 54 && projectile.owner < 255 && Main.player[projectile.owner].killClothier))) || - (projectile.hostile && Main.npc[i].friendly && !Main.npc[i].dontTakeDamageFromHostiles)) && (projectile.owner < 0 || Main.npc[i].immune[projectile.owner] == 0 || projectile.maxPenetrate == 1)) - { - if (Main.npc[i].noTileCollide || !projectile.ownerHitCheck || projectile.CanHit(Main.npc[i])) - { - bool flag3; - if (Main.npc[i].type == 414) - { - Rectangle rect = Main.npc[i].getRect(); - int num5 = 8; - rect.X -= num5; - rect.Y -= num5; - rect.Width += num5 * 2; - rect.Height += num5 * 2; - flag3 = projectile.Colliding(myRect, rect); - } - else - { - flag3 = projectile.Colliding(myRect, Main.npc[i].getRect()); - } - if (flag3) - { - if (Main.npc[i].reflectingProjectiles && projectile.CanReflect()) - { - Main.npc[i].ReflectProjectile(projectile.whoAmI); - return; - } - projectile.ai[0] = 1f; - projectile.timeLeft = 900; //increase lifetime if sticking to something - projectile.ai[1] = (float)i; - projectile.velocity = (Main.npc[i].Center - projectile.Center) * 0.75f; - projectile.netUpdate = true; - projectile.StatusNPC(i); - //projectile.damage = 0; //aaaaaaa - int num28 = 1; - Point[] array2 = new Point[num28]; - int num29 = 0; - for (int l = 0; l < 1000; l++) - { - if (l != projectile.whoAmI && Main.projectile[l].active && Main.projectile[l].owner == Main.myPlayer && Main.projectile[l].type == projectile.type && Main.projectile[l].ai[0] == 1f && Main.projectile[l].ai[1] == (float)i) - { - array2[num29++] = new Point(l, Main.projectile[l].timeLeft); - if (num29 >= array2.Length) - { - break; - } - } - } - if (num29 >= array2.Length) - { - int num30 = 0; - for (int m = 1; m < array2.Length; m++) - { - if (array2[m].Y < array2[num30].Y) - { - num30 = m; - } - } - Main.projectile[array2[num30].X].Kill(); - } - } - } - } - } - } + CalamityUtils.ModifyHitNPCSticky(projectile, 1, true); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) diff --git a/Projectiles/Rogue/FantasyTalismanProj.cs b/Projectiles/Rogue/FantasyTalismanProj.cs index 24c18b7275..5d14ce2f96 100644 --- a/Projectiles/Rogue/FantasyTalismanProj.cs +++ b/Projectiles/Rogue/FantasyTalismanProj.cs @@ -9,8 +9,6 @@ namespace CalamityMod.Projectiles.Rogue { public class FantasyTalismanProj : ModProjectile { - int spiritTimer = 0; - public override void SetStaticDefaults() { DisplayName.SetDefault("Talisman"); @@ -26,7 +24,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.Calamity().rogue = true; projectile.ignoreWater = true; projectile.aiStyle = 1; - aiType = 242; + aiType = ProjectileID.BulletHighVelocity; projectile.penetrate = -1; projectile.timeLeft = 600; projectile.usesLocalNPCImmunity = true; @@ -41,64 +39,25 @@ namespace CalamityMod.Projectiles.Rogue { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 175, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } + CalamityUtils.StickyProjAI(projectile, 15); if (projectile.ai[0] == 1f) { - projectile.tileCollide = false; - int num988 = 15; - bool flag54 = false; - bool flag55 = false; - float[] var_2_2CB4E_cp_0 = projectile.localAI; - int var_2_2CB4E_cp_1 = 0; - float num73 = var_2_2CB4E_cp_0[var_2_2CB4E_cp_1]; - var_2_2CB4E_cp_0[var_2_2CB4E_cp_1] = num73 + 1f; - if (projectile.localAI[0] % 30f == 0f) - { - flag55 = true; - } - int num989 = (int)projectile.ai[1]; - if (projectile.localAI[0] >= (float)(60 * num988)) - { - flag54 = true; - } - else if (num989 < 0 || num989 >= 200) - { - flag54 = true; - } - else if (Main.npc[num989].active && !Main.npc[num989].dontTakeDamage) - { - projectile.Center = Main.npc[num989].Center - projectile.velocity * 2f; - projectile.gfxOffY = Main.npc[num989].gfxOffY; - if (flag55) - { - Main.npc[num989].HitEffect(0, 1.0); - } - } - else - { - flag54 = true; - } - if (flag54) - { - projectile.Kill(); - } - spiritTimer++; - if (spiritTimer >= 10) + if (projectile.timeLeft % 10 == 0) { - spiritTimer = 0; if (Main.rand.NextBool(2)) { int spiritDamage = projectile.damage / 2; - int[] numArray1 = new int[200]; + int[] numArray1 = new int[Main.maxNPCs]; int maxValue1 = 0; int maxValue2 = 0; - for (int index = 0; index < 200; ++index) + for (int index = 0; index < Main.maxNPCs; ++index) { if (Main.npc[index].CanBeChasedBy((object) projectile, false)) { - float num2 = Math.Abs(Main.npc[index].position.X + (float) (Main.npc[index].width / 2) - projectile.position.X + (float) (projectile.width / 2)) + Math.Abs(Main.npc[index].position.Y + (float) (Main.npc[index].height / 2) - projectile.position.Y + (float) (projectile.height / 2)); - if ((double) num2 < 800.0) + float num2 = Math.Abs(Main.npc[index].Center.X - projectile.Center.X) + Math.Abs(Main.npc[index].Center.Y - projectile.Center.Y); + if (num2 < 800f) { - if (Collision.CanHit(projectile.position, 1, 1, Main.npc[index].position, Main.npc[index].width, Main.npc[index].height) && (double) num2 > 50.0) + if (Collision.CanHit(projectile.position, 1, 1, Main.npc[index].position, Main.npc[index].width, Main.npc[index].height) && num2 > 50f) { numArray1[maxValue2] = index; ++maxValue2; @@ -121,7 +80,7 @@ namespace CalamityMod.Projectiles.Rogue float num8 = (float) (num4 / num7); float SpeedX = num5 * num8; float SpeedY = num6 * num8; - int ghost = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, SpeedX, SpeedY, ProjectileID.SpectreWrath, spiritDamage, 0.0f, projectile.owner, (float) num3, 0.0f); + int ghost = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, SpeedX, SpeedY, ProjectileID.SpectreWrath, spiritDamage, 0.0f, projectile.owner, (float)num3, 0f); Main.projectile[ghost].Calamity().forceRogue = true; Main.projectile[ghost].penetrate = 1; } @@ -137,75 +96,7 @@ namespace CalamityMod.Projectiles.Rogue public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - Rectangle myRect = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < 200; i++) - { - if (Main.npc[i].active && !Main.npc[i].dontTakeDamage && - ((projectile.friendly && (!Main.npc[i].friendly || projectile.type == 318 || (Main.npc[i].type == 22 && projectile.owner < 255 && Main.player[projectile.owner].killGuide) || (Main.npc[i].type == 54 && projectile.owner < 255 && Main.player[projectile.owner].killClothier))) || - (projectile.hostile && Main.npc[i].friendly && !Main.npc[i].dontTakeDamageFromHostiles)) && (projectile.owner < 0 || Main.npc[i].immune[projectile.owner] == 0 || projectile.maxPenetrate == 1)) - { - if (Main.npc[i].noTileCollide || !projectile.ownerHitCheck || projectile.CanHit(Main.npc[i])) - { - bool flag3; - if (Main.npc[i].type == 414) - { - Rectangle rect = Main.npc[i].getRect(); - int num5 = 8; - rect.X -= num5; - rect.Y -= num5; - rect.Width += num5 * 2; - rect.Height += num5 * 2; - flag3 = projectile.Colliding(myRect, rect); - } - else - { - flag3 = projectile.Colliding(myRect, Main.npc[i].getRect()); - } - if (flag3) - { - if (Main.npc[i].reflectingProjectiles && projectile.CanReflect()) - { - Main.npc[i].ReflectProjectile(projectile.whoAmI); - return; - } - projectile.ai[0] = 1f; - projectile.ai[1] = (float)i; - projectile.velocity = (Main.npc[i].Center - projectile.Center) * 0.75f; - projectile.netUpdate = true; - projectile.StatusNPC(i); - int num28 = 3; - Point[] array2 = new Point[num28]; - int num29 = 0; - for (int l = 0; l < 1000; l++) - { - if (l != projectile.whoAmI && Main.projectile[l].active && Main.projectile[l].owner == Main.myPlayer && Main.projectile[l].type == projectile.type && Main.projectile[l].ai[0] == 1f && Main.projectile[l].ai[1] == (float)i) - { - array2[num29++] = new Point(l, Main.projectile[l].timeLeft); - if (num29 >= array2.Length) - { - break; - } - } - } - if (num29 >= array2.Length) - { - int num30 = 0; - for (int m = 1; m < array2.Length; m++) - { - if (array2[m].Y < array2[num30].Y) - { - num30 = m; - } - } - Main.projectile[array2[num30].X].Kill(); - } - } - } - } - } - } + CalamityUtils.ModifyHitNPCSticky(projectile, 3, true); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) diff --git a/Projectiles/Rogue/FantasyTalismanStealth.cs b/Projectiles/Rogue/FantasyTalismanStealth.cs index 3e9d0511c6..4b6a606947 100644 --- a/Projectiles/Rogue/FantasyTalismanStealth.cs +++ b/Projectiles/Rogue/FantasyTalismanStealth.cs @@ -9,9 +9,6 @@ namespace CalamityMod.Projectiles.Rogue { public class FantasyTalismanStealth : ModProjectile { - int spiritTimer = 0; - int stealthTimer = 10; - public override void SetStaticDefaults() { DisplayName.SetDefault("Talisman"); @@ -27,7 +24,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.Calamity().rogue = true; projectile.ignoreWater = true; projectile.aiStyle = 1; - aiType = 242; + aiType = ProjectileID.BulletHighVelocity; projectile.penetrate = -1; projectile.timeLeft = 600; projectile.usesLocalNPCImmunity = true; @@ -44,8 +41,7 @@ namespace CalamityMod.Projectiles.Rogue } if (projectile.ai[0] != 1f) { - stealthTimer--; - if (stealthTimer == 0) + if (projectile.timeLeft % 10 == 0) { if (projectile.owner == Main.myPlayer) { @@ -54,67 +50,27 @@ namespace CalamityMod.Projectiles.Rogue Main.projectile[sGhost].penetrate = 1; Main.projectile[sGhost].timeLeft = 240; } - stealthTimer = 10; } } + CalamityUtils.StickyProjAI(projectile, 15); if (projectile.ai[0] == 1f) { - projectile.tileCollide = false; - int num988 = 15; - bool flag54 = false; - bool flag55 = false; - float[] var_2_2CB4E_cp_0 = projectile.localAI; - int var_2_2CB4E_cp_1 = 0; - float num73 = var_2_2CB4E_cp_0[var_2_2CB4E_cp_1]; - var_2_2CB4E_cp_0[var_2_2CB4E_cp_1] = num73 + 1f; - if (projectile.localAI[0] % 30f == 0f) - { - flag55 = true; - } - int num989 = (int)projectile.ai[1]; - if (projectile.localAI[0] >= (float)(60 * num988)) - { - flag54 = true; - } - else if (num989 < 0 || num989 >= 200) - { - flag54 = true; - } - else if (Main.npc[num989].active && !Main.npc[num989].dontTakeDamage) - { - projectile.Center = Main.npc[num989].Center - projectile.velocity * 2f; - projectile.gfxOffY = Main.npc[num989].gfxOffY; - if (flag55) - { - Main.npc[num989].HitEffect(0, 1.0); - } - } - else - { - flag54 = true; - } - if (flag54) - { - projectile.Kill(); - } - spiritTimer += 3; - if (spiritTimer >= 10) + if (projectile.timeLeft % 4 == 0) { - spiritTimer = 0; if (Main.rand.NextBool(2)) { int spiritDamage = projectile.damage / 2; - int[] numArray1 = new int[200]; + int[] numArray1 = new int[Main.maxNPCs]; int maxValue1 = 0; int maxValue2 = 0; - for (int index = 0; index < 200; ++index) + for (int index = 0; index < Main.maxNPCs; ++index) { if (Main.npc[index].CanBeChasedBy((object) projectile, false)) { - float num2 = Math.Abs(Main.npc[index].position.X + (float) (Main.npc[index].width / 2) - projectile.position.X + (float) (projectile.width / 2)) + Math.Abs(Main.npc[index].position.Y + (float) (Main.npc[index].height / 2) - projectile.position.Y + (float) (projectile.height / 2)); - if ((double) num2 < 800.0) + float num2 = Math.Abs(Main.npc[index].Center.X - projectile.Center.X) + Math.Abs(Main.npc[index].Center.Y - projectile.Center.Y); + if (num2 < 800f) { - if (Collision.CanHit(projectile.position, 1, 1, Main.npc[index].position, Main.npc[index].width, Main.npc[index].height) && (double) num2 > 50.0) + if (Collision.CanHit(projectile.position, 1, 1, Main.npc[index].position, Main.npc[index].width, Main.npc[index].height) && num2 > 50f) { numArray1[maxValue2] = index; ++maxValue2; @@ -137,7 +93,7 @@ namespace CalamityMod.Projectiles.Rogue float num8 = (float) (num4 / num7); float SpeedX = num5 * num8; float SpeedY = num6 * num8; - int ghost = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, SpeedX, SpeedY, ProjectileID.SpectreWrath, spiritDamage, 0.0f, projectile.owner, (float) num3, 0.0f); + int ghost = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, SpeedX, SpeedY, ProjectileID.SpectreWrath, spiritDamage, 0.0f, projectile.owner, (float)num3, 0f); Main.projectile[ghost].Calamity().forceRogue = true; Main.projectile[ghost].penetrate = 1; } @@ -153,75 +109,7 @@ namespace CalamityMod.Projectiles.Rogue public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - Rectangle myRect = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < 200; i++) - { - if (Main.npc[i].active && !Main.npc[i].dontTakeDamage && - ((projectile.friendly && (!Main.npc[i].friendly || projectile.type == 318 || (Main.npc[i].type == 22 && projectile.owner < 255 && Main.player[projectile.owner].killGuide) || (Main.npc[i].type == 54 && projectile.owner < 255 && Main.player[projectile.owner].killClothier))) || - (projectile.hostile && Main.npc[i].friendly && !Main.npc[i].dontTakeDamageFromHostiles)) && (projectile.owner < 0 || Main.npc[i].immune[projectile.owner] == 0 || projectile.maxPenetrate == 1)) - { - if (Main.npc[i].noTileCollide || !projectile.ownerHitCheck || projectile.CanHit(Main.npc[i])) - { - bool flag3; - if (Main.npc[i].type == 414) - { - Rectangle rect = Main.npc[i].getRect(); - int num5 = 8; - rect.X -= num5; - rect.Y -= num5; - rect.Width += num5 * 2; - rect.Height += num5 * 2; - flag3 = projectile.Colliding(myRect, rect); - } - else - { - flag3 = projectile.Colliding(myRect, Main.npc[i].getRect()); - } - if (flag3) - { - if (Main.npc[i].reflectingProjectiles && projectile.CanReflect()) - { - Main.npc[i].ReflectProjectile(projectile.whoAmI); - return; - } - projectile.ai[0] = 1f; - projectile.ai[1] = (float)i; - projectile.velocity = (Main.npc[i].Center - projectile.Center) * 0.75f; - projectile.netUpdate = true; - projectile.StatusNPC(i); - int num28 = 1; - Point[] array2 = new Point[num28]; - int num29 = 0; - for (int l = 0; l < 1000; l++) - { - if (l != projectile.whoAmI && Main.projectile[l].active && Main.projectile[l].owner == Main.myPlayer && Main.projectile[l].type == projectile.type && Main.projectile[l].ai[0] == 1f && Main.projectile[l].ai[1] == (float)i) - { - array2[num29++] = new Point(l, Main.projectile[l].timeLeft); - if (num29 >= array2.Length) - { - break; - } - } - } - if (num29 >= array2.Length) - { - int num30 = 0; - for (int m = 1; m < array2.Length; m++) - { - if (array2[m].Y < array2[num30].Y) - { - num30 = m; - } - } - Main.projectile[array2[num30].X].Kill(); - } - } - } - } - } - } + CalamityUtils.ModifyHitNPCSticky(projectile, 1, true); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) diff --git a/Projectiles/Rogue/FeatherKnifeProjectile.cs b/Projectiles/Rogue/FeatherKnifeProjectile.cs index 33fe5ad8c2..8c088e0300 100644 --- a/Projectiles/Rogue/FeatherKnifeProjectile.cs +++ b/Projectiles/Rogue/FeatherKnifeProjectile.cs @@ -9,8 +9,6 @@ namespace CalamityMod.Projectiles.Rogue { public class FeatherKnifeProjectile : ModProjectile { - private int featherTimer = 35; - public override void SetStaticDefaults() { DisplayName.SetDefault("Knife"); @@ -36,21 +34,19 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - if (featherTimer == 0) + if (projectile.timeLeft % 35 == 0) { if (projectile.owner == Main.myPlayer) { - int proj = Projectile.NewProjectile(projectile.position, new Vector2(projectile.velocity.X / 20, 2), ModContent.ProjectileType(), (int)((double)projectile.damage * 0.4), projectile.knockBack, projectile.owner); + int proj = Projectile.NewProjectile(projectile.position, new Vector2(projectile.velocity.X / 20, 2), ModContent.ProjectileType(), (int)(projectile.damage * 0.4), projectile.knockBack, projectile.owner); Main.projectile[proj].Calamity().forceRogue = true; } - featherTimer = 35; } - featherTimer--; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - int proj = Projectile.NewProjectile(projectile.position, new Vector2(projectile.velocity.X / 20, 2), ModContent.ProjectileType(), (int)((double)projectile.damage * 0.69), projectile.knockBack, projectile.owner); + int proj = Projectile.NewProjectile(projectile.position, new Vector2(projectile.velocity.X / 20, 2), ModContent.ProjectileType(), (int)(projectile.damage * 0.69), projectile.knockBack, projectile.owner); Main.projectile[proj].Calamity().forceRogue = true; } diff --git a/Projectiles/Rogue/ShinobiBladeProjectile.cs b/Projectiles/Rogue/ShinobiBladeProjectile.cs index 19d008caaa..af1ab201fa 100644 --- a/Projectiles/Rogue/ShinobiBladeProjectile.cs +++ b/Projectiles/Rogue/ShinobiBladeProjectile.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Rogue { if (target.life <= 0) { - Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0, Main.myPlayer, 0, 10); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], 10, ModContent.ProjectileType(), 1200f, 0f); } } @@ -65,7 +65,7 @@ namespace CalamityMod.Projectiles.Rogue { if (target.statLife <= 0) { - Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0, Main.myPlayer, 0, 10); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], 10, ModContent.ProjectileType(), 1200f, 0f); } } diff --git a/Projectiles/Rogue/SphereSpiked.cs b/Projectiles/Rogue/SphereSpiked.cs index 34d6245d01..7808ab9153 100644 --- a/Projectiles/Rogue/SphereSpiked.cs +++ b/Projectiles/Rogue/SphereSpiked.cs @@ -29,24 +29,31 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { Lighting.AddLight(projectile.Center, 1f, 0f, 0f); - if (projectile.timeLeft == 300) - projectile.damage *= (int)1.2f; if (Main.rand.NextBool(5)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 229, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, 100); } + if (projectile.ai[0] == 1f) + { + projectile.extraUpdates = 1; + } } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - Main.PlaySound(3, (int)projectile.Center.X, (int)projectile.Center.Y, 34); - if (Main.rand.NextBool(10)) //idk if this even works + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + damage = (int)(damage * 1.2); + if (Main.rand.NextBool(10)) { if (!crit) crit = true; } } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + Main.PlaySound(3, (int)projectile.Center.X, (int)projectile.Center.Y, 34); + } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); diff --git a/Projectiles/Rogue/SphereYellow.cs b/Projectiles/Rogue/SphereYellow.cs index cdcbe0b3f6..9ef1d54930 100644 --- a/Projectiles/Rogue/SphereYellow.cs +++ b/Projectiles/Rogue/SphereYellow.cs @@ -33,6 +33,10 @@ namespace CalamityMod.Projectiles.Rogue { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 229, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, 100); } + if (projectile.ai[0] == 1f) + { + projectile.extraUpdates = 1; + } } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Rogue/SylvanSlashAttack.cs b/Projectiles/Rogue/SylvanSlashAttack.cs index b37be1ec9d..72c1212f54 100644 --- a/Projectiles/Rogue/SylvanSlashAttack.cs +++ b/Projectiles/Rogue/SylvanSlashAttack.cs @@ -29,6 +29,9 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { + if (Main.myPlayer != projectile.owner) + return; + Player player = Main.player[projectile.owner]; float num = 0f; Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); @@ -46,33 +49,30 @@ namespace CalamityMod.Projectiles.Rogue Main.PlaySound(SoundID.Item15, projectile.Center); projectile.soundDelay = 24; } - if (Main.myPlayer == projectile.owner) - { - if (player.channel && !player.noItems && !player.CCed) - { - float scaleFactor6 = 1f; - if (player.inventory[player.selectedItem].shoot == projectile.type) - { - scaleFactor6 = player.inventory[player.selectedItem].shootSpeed * projectile.scale; - } - Vector2 vector13 = Main.MouseWorld - vector; - vector13.Normalize(); - if (vector13.HasNaNs()) - { - vector13 = Vector2.UnitX * (float)player.direction; - } - vector13 *= scaleFactor6; - if (vector13.X != projectile.velocity.X || vector13.Y != projectile.velocity.Y) - { - projectile.netUpdate = true; - } - projectile.velocity = vector13; - } - else - { - projectile.Kill(); - } - } + if (player.channel && !player.noItems && !player.CCed) + { + float scaleFactor6 = 1f; + if (player.ActiveItem().shoot == projectile.type) + { + scaleFactor6 = player.ActiveItem().shootSpeed * projectile.scale; + } + Vector2 vector13 = Main.MouseWorld - vector; + vector13.Normalize(); + if (vector13.HasNaNs()) + { + vector13 = Vector2.UnitX * (float)player.direction; + } + vector13 *= scaleFactor6; + if (vector13.X != projectile.velocity.X || vector13.Y != projectile.velocity.Y) + { + projectile.netUpdate = true; + } + projectile.velocity = vector13; + } + else + { + projectile.Kill(); + } Vector2 vector14 = projectile.Center + projectile.velocity * 3f; Lighting.AddLight(vector14, 0.2f, 2f, 3f); if (Main.rand.NextBool(3)) diff --git a/Projectiles/Rogue/TimeBoltKnife.cs b/Projectiles/Rogue/TimeBoltKnife.cs index 1b2560fb26..434a30df09 100644 --- a/Projectiles/Rogue/TimeBoltKnife.cs +++ b/Projectiles/Rogue/TimeBoltKnife.cs @@ -79,31 +79,31 @@ namespace CalamityMod.Projectiles.Rogue if (Main.rand.Next(6) != 0) dust2.noGravity = true; } - float num773 = 0.01f; - int num774 = 5; - int num775 = num774 * 15; - int num776 = 0; + float scalar = 0.01f; + int alphaAmt = 5; + int alphaCeiling = alphaAmt * 15; + int alphaFloor = 0; if (projectile.localAI[0] > 7f) { if (projectile.localAI[1] == 0f) { - projectile.scale -= num773; + projectile.scale -= scalar; - projectile.alpha += num774; - if (projectile.alpha > num775) + projectile.alpha += alphaAmt; + if (projectile.alpha > alphaCeiling) { - projectile.alpha = num775; + projectile.alpha = alphaCeiling; projectile.localAI[1] = 1f; } } else if (projectile.localAI[1] == 1f) { - projectile.scale += num773; + projectile.scale += scalar; - projectile.alpha -= num774; - if (projectile.alpha <= num776) + projectile.alpha -= alphaAmt; + if (projectile.alpha <= alphaFloor) { - projectile.alpha = num776; + projectile.alpha = alphaFloor; projectile.localAI[1] = 0f; } } @@ -127,32 +127,29 @@ namespace CalamityMod.Projectiles.Rogue } int whoAmI = -1; - Vector2 value19 = projectile.Center; - float num778 = 300f; - int j; - for (int i = 0; i < 200; i = j + 1) + Vector2 targetSpot = projectile.Center; + float detectRange = 400f; + for (int i = 0; i < Main.maxNPCs; i++) { - NPC nPC = Main.npc[i]; - if (nPC.CanBeChasedBy(projectile, false)) + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) { - Vector2 center = nPC.Center; - float num780 = Vector2.Distance(center, projectile.Center); - if (num780 < num778) + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (targetDist < detectRange) { - num778 = num780; - value19 = center; + detectRange = targetDist; + targetSpot = npc.Center; whoAmI = i; } } - j = i; } if (whoAmI >= 0) { projectile.netUpdate = true; projectile.ai[0] += (float)penetrationAmt; - projectile.position = value19 + ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * 100f - new Vector2((float)projectile.width, (float)projectile.height) / 2f; - projectile.velocity = Vector2.Normalize(value19 - projectile.Center) * 18f; + projectile.position = targetSpot + ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * 100f - new Vector2((float)projectile.width, (float)projectile.height) / 2f; + projectile.velocity = Vector2.Normalize(targetSpot - projectile.Center) * 18f; } else projectile.Kill(); @@ -221,10 +218,7 @@ namespace CalamityMod.Projectiles.Rogue Lighting.AddLight((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16, 0.3f * colorScale, 0.4f * colorScale, 1f * colorScale); } - public override Color? GetAlpha(Color lightColor) - { - return new Color(255, 255, 255, 200) * ((255f - (float)projectile.alpha) / 255f); - } + public override Color? GetAlpha(Color lightColor) => new Color(255, 255, 255, 200) * ((255f - (float)projectile.alpha) / 255f); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -283,7 +277,7 @@ namespace CalamityMod.Projectiles.Rogue { Main.PlaySound(SoundID.Item114, projectile.Center); - int radius = projectile.Calamity().stealthStrike ? 500 : 300; + float radius = projectile.Calamity().stealthStrike ? 500f : 300f; int numDust = (int)(0.2f * MathHelper.TwoPi * radius); float angleIncrement = MathHelper.TwoPi / (float)numDust; Vector2 dustOffset = new Vector2(radius, 0f); @@ -292,10 +286,10 @@ namespace CalamityMod.Projectiles.Rogue { dustOffset = dustOffset.RotatedBy(angleIncrement); int dustType = Utils.SelectRandom(Main.rand, new int[] - { + { 226, 229 - }); + }); int dust = Dust.NewDust(projectile.Center, 1, 1, dustType); Main.dust[dust].position = projectile.Center + dustOffset; if (Main.rand.Next(6) != 0) @@ -309,11 +303,11 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i < Main.maxNPCs; i++) { - NPC nPC = Main.npc[i]; - if (nPC.active && !nPC.dontTakeDamage && !nPC.buffImmune[buffType] && Vector2.Distance(projectile.Center, nPC.Center) <= (float)radius) + NPC npc = Main.npc[i]; + if (npc.active && !npc.dontTakeDamage && !npc.buffImmune[buffType] && Vector2.Distance(projectile.Center, npc.Center) <= radius) { - if (nPC.FindBuffIndex(buffType) == -1) - nPC.AddBuff(buffType, 180, false); + if (npc.FindBuffIndex(buffType) == -1) + npc.AddBuff(buffType, 180, false); } } } diff --git a/Projectiles/Summon/AquaticStarMinion.cs b/Projectiles/Summon/AquaticStarMinion.cs index 1fc75cb697..012c839454 100644 --- a/Projectiles/Summon/AquaticStarMinion.cs +++ b/Projectiles/Summon/AquaticStarMinion.cs @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Summon float num634 = 800f; float num635 = 1200f; float num636 = 150f; - float num637 = 0.05f; + float SAIMovement = 0.05f; for (int num638 = 0; num638 < Main.maxProjectiles; num638++) { bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); @@ -76,19 +76,19 @@ namespace CalamityMod.Projectiles.Summon { if (projectile.position.X < Main.projectile[num638].position.X) { - projectile.velocity.X = projectile.velocity.X - num637; + projectile.velocity.X -= SAIMovement; } else { - projectile.velocity.X = projectile.velocity.X + num637; + projectile.velocity.X += SAIMovement; } if (projectile.position.Y < Main.projectile[num638].position.Y) { - projectile.velocity.Y = projectile.velocity.Y - num637; + projectile.velocity.Y -= SAIMovement; } else { - projectile.velocity.Y = projectile.velocity.Y + num637; + projectile.velocity.Y += SAIMovement; } } } diff --git a/Projectiles/Summon/BrimstoneFireballMinion.cs b/Projectiles/Summon/BrimstoneFireballMinion.cs index 0d33e06164..7faee65129 100644 --- a/Projectiles/Summon/BrimstoneFireballMinion.cs +++ b/Projectiles/Summon/BrimstoneFireballMinion.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -12,6 +13,9 @@ namespace CalamityMod.Projectiles.Summon { DisplayName.SetDefault("Brimfire"); ProjectileID.Sets.MinionShot[projectile.type] = true; + Main.projFrames[projectile.type] = 6; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; } public override void SetDefaults() @@ -26,23 +30,44 @@ namespace CalamityMod.Projectiles.Summon projectile.minion = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; + projectile.alpha = 255; } public override void AI() { - Lighting.AddLight(projectile.Center, 0.6f, 0f, 0f); + //Animation + projectile.frameCounter++; + if (projectile.frameCounter > 9) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= 6) + { + projectile.frame = 0; + } + + //Fade in + if (projectile.alpha > 5) + projectile.alpha -= 15; + if (projectile.alpha < 5) + projectile.alpha = 5; + + //Rotation + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) - MathHelper.ToRadians(90) * projectile.direction; + + int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 170, default, 1.1f); + Main.dust[num458].noGravity = true; + Main.dust[num458].velocity *= 0.5f; + Main.dust[num458].velocity += projectile.velocity * 0.1f; + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.05f / 255f, (255 - projectile.alpha) * 0.05f / 255f); + if (projectile.localAI[0] == 0f) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20); projectile.localAI[0] += 1f; } - for (int num457 = 0; num457 < 3; num457++) - { - int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += projectile.velocity * 0.1f; - } } public override void Kill(int timeLeft) @@ -57,5 +82,11 @@ namespace CalamityMod.Projectiles.Summon { target.AddBuff(ModContent.BuffType(), 600); } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); + return false; + } } } diff --git a/Projectiles/Summon/BrimstoneFireballMinion.png b/Projectiles/Summon/BrimstoneFireballMinion.png index 831f72cfc8..71720f8c11 100644 Binary files a/Projectiles/Summon/BrimstoneFireballMinion.png and b/Projectiles/Summon/BrimstoneFireballMinion.png differ diff --git a/Projectiles/Summon/CosmicViperSummon.cs b/Projectiles/Summon/CosmicViperSummon.cs index 195d4927db..54747653c6 100644 --- a/Projectiles/Summon/CosmicViperSummon.cs +++ b/Projectiles/Summon/CosmicViperSummon.cs @@ -43,16 +43,16 @@ namespace CalamityMod.Projectiles.Summon { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) { int dustType = Main.rand.NextBool(3) ? 56 : 242; Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * MathHelper.TwoPi / (float)num226), default) + projectile.Center; + vector6 = vector6.RotatedBy((double)((float)(dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + projectile.Center; Vector2 vector7 = vector6 - projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, dustType, vector7.X * 1.75f, vector7.Y * 1.75f, 100, default, 1.1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].velocity = vector7; + int dusty = Dust.NewDust(vector6 + vector7, 0, 0, dustType, vector7.X * 1.75f, vector7.Y * 1.75f, 100, default, 1.1f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].velocity = vector7; } projectile.localAI[0] += 1f; } @@ -75,9 +75,9 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; } - bool flag64 = projectile.type == ModContent.ProjectileType(); + bool correctMinion = projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + if (correctMinion) { if (player.dead) { @@ -92,131 +92,127 @@ namespace CalamityMod.Projectiles.Summon float colorScale = (float)projectile.alpha / 255f; Lighting.AddLight((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16, 1f * colorScale, 0.1f * colorScale, 1f * colorScale); - float num637 = 0.05f; - for (int num638 = 0; num638 < Main.maxProjectiles; num638++) + float antiStickyFloat = 0.05f; + for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) + Projectile proj = Main.projectile[projIndex]; + bool flag23 = proj.type == ModContent.ProjectileType(); + if (projIndex != projectile.whoAmI && proj.active && proj.owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) { - if (projectile.position.X < Main.projectile[num638].position.X) + if (projectile.position.X < proj.position.X) { - projectile.velocity.X = projectile.velocity.X - num637; + projectile.velocity.X -= antiStickyFloat; } else { - projectile.velocity.X = projectile.velocity.X + num637; + projectile.velocity.X += antiStickyFloat; } - if (projectile.position.Y < Main.projectile[num638].position.Y) + if (projectile.position.Y < proj.position.Y) { - projectile.velocity.Y = projectile.velocity.Y - num637; + projectile.velocity.Y -= antiStickyFloat; } else { - projectile.velocity.Y = projectile.velocity.Y + num637; + projectile.velocity.Y += antiStickyFloat; } } } - float num633 = 700f; - float num634 = 1300f; - float num635 = 2600f; - float num636 = 600f; - Vector2 vector46 = projectile.position; - bool flag25 = false; + float detectRange = 700f; + Vector2 targetVec = projectile.position; + bool foundTarget = false; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(projectile, false)) { - float num646 = Vector2.Distance(npc.Center, projectile.Center); - if (!flag25 && num646 < num633) + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && targetDist < detectRange) { - num633 = num646; - vector46 = npc.Center; - flag25 = true; + detectRange = targetDist; + targetVec = npc.Center; + foundTarget = true; } } } else { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) { - NPC nPC2 = Main.npc[num645]; - if (nPC2.CanBeChasedBy(projectile, false)) + NPC npc = Main.npc[npcIndex]; + if (npc.CanBeChasedBy(projectile, false)) { - float num646 = Vector2.Distance(nPC2.Center, projectile.Center); - if (!flag25 && num646 < num633) + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && targetDist < detectRange) { - num633 = num646; - vector46 = nPC2.Center; - flag25 = true; + detectRange = targetDist; + targetVec = npc.Center; + foundTarget = true; } } } } - float num647 = num634; - if (flag25) + float returnDist = 1300f; + if (foundTarget) { - num647 = num635; + returnDist = 2600f; } - if (Vector2.Distance(player.Center, projectile.Center) > num647) + if (Vector2.Distance(player.Center, projectile.Center) > returnDist) { projectile.ai[0] = 1f; projectile.netUpdate = true; } - if (flag25 && projectile.ai[0] == 0f) + if (foundTarget && projectile.ai[0] == 0f) { - Vector2 vector47 = vector46 - projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) + Vector2 targetVector = targetVec - projectile.Center; + float targetDist = targetVector.Length(); + targetVector.Normalize(); + float speedMult = 18f; //12 + if (targetDist > 200f) { - float scaleFactor2 = 18f; //12 - vector47 *= scaleFactor2; - projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; + targetVector *= speedMult; + projectile.velocity = (projectile.velocity * 40f + targetVector) / 41f; } else { - float num649 = 9f; - vector47 *= -num649; - projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; + targetVector *= -(speedMult / 2); + projectile.velocity = (projectile.velocity * 40f + targetVector) / 41f; } } else { - bool flag26 = false; - if (!flag26) + float safeDist = 600f; + bool returnToPlayer = false; + if (!returnToPlayer) { - flag26 = projectile.ai[0] == 1f; + returnToPlayer = projectile.ai[0] == 1f; } - float num650 = 12f; - if (flag26) + float velocityMult = 12f; + if (returnToPlayer) { - num650 = 30f; + velocityMult = 30f; } - Vector2 center2 = projectile.Center; - Vector2 vector48 = player.Center - center2 + new Vector2(0f, -120f); - float num651 = vector48.Length(); - if (num651 > 200f && num650 < 16f) + Vector2 playerVec = player.Center - projectile.Center + new Vector2(0f, -120f); + float playerDist = playerVec.Length(); + if (playerDist > 200f && velocityMult < 16f) { - num650 = 16f; + velocityMult = 16f; } - if (num651 < num636 && flag26) + if (playerDist < safeDist && returnToPlayer) { projectile.ai[0] = 0f; projectile.netUpdate = true; } - if (num651 > 2000f) + if (playerDist > 2000f) { - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); + projectile.Center = player.Center; projectile.netUpdate = true; } - if (num651 > 70f) + if (playerDist > 70f) { - vector48.Normalize(); - vector48 *= num650; - projectile.velocity = (projectile.velocity * 40f + vector48) / 41f; + playerVec.Normalize(); + playerVec *= velocityMult; + projectile.velocity = (projectile.velocity * 40f + playerVec) / 41f; } else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) { @@ -224,24 +220,24 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity.Y = -0.05f; } } - if (flag25) + if (foundTarget) { - projectile.rotation = (vector46 - projectile.Center).ToRotation() + MathHelper.Pi; + projectile.rotation = (targetVec - projectile.Center).ToRotation() + MathHelper.Pi; } else { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi; - for (int num369 = 0; num369 < 1; num369++) + for (int index = 0; index < 1; index++) { int dustType = Main.rand.NextBool(3) ? 56 : 242; - float num370 = projectile.velocity.X / 3f * (float)num369; - float num371 = projectile.velocity.Y / 3f * (float)num369; + float num370 = projectile.velocity.X / 3f * (float)index; + float num371 = projectile.velocity.Y / 3f * (float)index; int num372 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 1f); - Main.dust[num372].position.X = projectile.Center.X - num370; - Main.dust[num372].position.Y = projectile.Center.Y - num371; Dust dust = Main.dust[num372]; + dust.position.X = projectile.Center.X - num370; + dust.position.Y = projectile.Center.Y - num371; dust.velocity *= 0f; - Main.dust[num372].scale = 0.5f; + dust.scale = 0.5f; } } if (projectile.ai[1] > 0f) @@ -255,8 +251,8 @@ namespace CalamityMod.Projectiles.Summon } if (projectile.ai[0] == 0f) { - float scaleFactor3 = 6f; - if (flag25 && projectile.ai[1] == 0f) + float speedMult = 6f; + if (foundTarget && projectile.ai[1] == 0f) { //play cool sound Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20); @@ -281,25 +277,22 @@ namespace CalamityMod.Projectiles.Summon dmgMult = 1.5f; } - Vector2 value19 = vector46 - projectile.Center; - value19.Normalize(); - value19 *= scaleFactor3; + Vector2 velocity = targetVec - projectile.Center; + velocity.Normalize(); + velocity *= speedMult; //add some inaccuracy - value19.Y += Main.rand.Next(-30, 31) * 0.05f; - value19.X += Main.rand.Next(-30, 31) * 0.05f; + velocity.Y += Main.rand.NextFloat(-30f, 30f) * 0.05f; + velocity.X += Main.rand.NextFloat(-30f, 30f) * 0.05f; - int missile = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value19.X, value19.Y, projType, (int)(projectile.damage * dmgMult), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, velocity, projType, (int)(projectile.damage * dmgMult), projectile.knockBack, projectile.owner, 0f, 0f); projectile.netUpdate = true; } } } } - public override bool CanDamage() - { - return false; - } + public override bool CanDamage() => false; public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -310,7 +303,7 @@ namespace CalamityMod.Projectiles.Summon if (projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)frameHeight / 2f), projectile.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f); return false; } } diff --git a/Projectiles/Summon/ForbiddenCircletEater.cs b/Projectiles/Summon/ForbiddenCircletEater.cs index 636e4a175d..7b444099d2 100644 --- a/Projectiles/Summon/ForbiddenCircletEater.cs +++ b/Projectiles/Summon/ForbiddenCircletEater.cs @@ -72,7 +72,6 @@ namespace CalamityMod.Projectiles.Summon projectile.ai[0] += 1f; if (projectile.ai[0] > 30f) { - projectile.ai[0] = 30f; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; @@ -168,6 +167,7 @@ namespace CalamityMod.Projectiles.Summon } else { + projectile.ai[0] += 15f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; @@ -180,9 +180,6 @@ namespace CalamityMod.Projectiles.Summon return false; } - public override bool CanDamage() - { - return projectile.ai[0] >= 30f; - } + public override bool CanDamage() => projectile.ai[0] >= 30f; } } diff --git a/Projectiles/Summon/FungalClumpMinion.cs b/Projectiles/Summon/FungalClumpMinion.cs index bfe0d78b96..04f6c10f2b 100644 --- a/Projectiles/Summon/FungalClumpMinion.cs +++ b/Projectiles/Summon/FungalClumpMinion.cs @@ -1,6 +1,8 @@ using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Healing; +using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +11,8 @@ namespace CalamityMod.Projectiles.Summon { public class FungalClumpMinion : ModProjectile { + private bool returnToPlayer = false; + private bool amalgam = false; public override void SetStaticDefaults() { DisplayName.SetDefault("Fungal Clump"); @@ -25,7 +29,6 @@ namespace CalamityMod.Projectiles.Summon projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.minionSlots = 0f; - projectile.aiStyle = 54; projectile.timeLeft = 18000; projectile.penetrate = -1; projectile.timeLeft *= 5; @@ -35,15 +38,16 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - bool flag64 = projectile.type == ModContent.ProjectileType(); Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); + + bool correctMinion = projectile.type == ModContent.ProjectileType(); if (!modPlayer.fungalClump) { projectile.active = false; return; } - if (flag64) + if (correctMinion) { if (player.dead) { @@ -54,6 +58,9 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } + amalgam = projectile.ai[0] == 1f; + + //Initializing dust and damage if (projectile.localAI[0] == 0f) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); @@ -71,6 +78,8 @@ namespace CalamityMod.Projectiles.Summon } projectile.localAI[0] += 1f; } + + //Flexible damage correction if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / @@ -78,11 +87,178 @@ namespace CalamityMod.Projectiles.Summon player.MinionDamage()); projectile.damage = damage2; } + + //Periodically create dust if (Main.rand.NextBool(16)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 56, projectile.velocity.X * 0.05f, projectile.velocity.Y * 0.05f); } - } + + //Anti-sticky movement failsafe + float SAIMovement = 0.05f; + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + bool typeCheck = proj.type == ModContent.ProjectileType(); + if (i != projectile.whoAmI && proj.active && proj.owner == projectile.owner && typeCheck && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < (float)projectile.width) + { + if (projectile.position.X < proj.position.X) + { + projectile.velocity.X -= SAIMovement; + } + else + { + projectile.velocity.X += SAIMovement; + } + if (projectile.position.Y < proj.position.Y) + { + projectile.velocity.Y -= SAIMovement; + } + else + { + projectile.velocity.Y += SAIMovement; + } + } + } + + //If summoned by Amalgam, trail poisonous seawater + if (Math.Abs(projectile.velocity.X) > 0.1f || Math.Abs(projectile.velocity.Y) > 0.1f) + { + if (projectile.owner == Main.myPlayer) + { + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 1f, 0f); + } + } + + //If too far from player, increase speed to chase after player + float playerRange = 500f; + //Range is boosted if chasing after an enemy + if (projectile.ai[1] != 0f || projectile.friendly) + playerRange = amalgam ? 2000f : 1400f; + if (Math.Abs(projectile.Center.X - player.Center.X) + Math.Abs(projectile.Center.Y - player.Center.Y) > playerRange) + returnToPlayer = true; + + //Find an npc to target, or if minion targetting is used, choose that npc + Vector2 center = projectile.Center; + float range = 900f; + bool npcFound = false; + if (!returnToPlayer) + { + projectile.tileCollide = true; + NPC target = projectile.OwnerMinionAttackTargetNPC; + if (target != null && target.CanBeChasedBy(projectile, false)) + { + float extraDistance = (target.width / 2) + (target.height / 2); + + if (Vector2.Distance(target.Center, projectile.Center) < (range + extraDistance) && Collision.CanHit(projectile.position, projectile.width, projectile.height, target.position, target.width, target.height)) + { + center = target.Center; + npcFound = true; + } + } + if (!npcFound) + { + for (int index = 0; index < Main.maxNPCs; ++index) + { + NPC npc = Main.npc[index]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); + + if (Vector2.Distance(npc.Center, projectile.Center) < (range + extraDistance) && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) + { + center = npc.Center; + npcFound = true; + } + } + } + } + } + + //Tile collision depends on if returning to the player or not + projectile.tileCollide = !returnToPlayer; + + if (!npcFound) + { + projectile.friendly = true; + float homingSpeed = amalgam ? 12f : 8f; + float turnSpeed = 20f; + if (returnToPlayer) //move faster if returning to the player + homingSpeed = amalgam ? 30f : 12f; + Vector2 projPos = new Vector2(projectile.Center.X, projectile.Center.Y); + float xDist = player.Center.X - projPos.X; + float yDist = player.Center.Y - projPos.Y - 60f; + Vector2 playerVector = new Vector2(xDist, yDist); + float playerDist = playerVector.Length(); + if (playerDist < 100f && projectile.ai[0] == 1f && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + projectile.ai[0] = 0f; + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - projectile.width / 2; + projectile.position.Y = player.Center.Y - projectile.width / 2; + } + if (playerDist > 70f) + { + Vector2 homeInVector = projectile.DirectionTo(playerVector); + if (homeInVector.HasNaNs()) + homeInVector = Vector2.UnitY; + + projectile.velocity = (projectile.velocity * turnSpeed + homeInVector * homingSpeed) / (turnSpeed + 1f); + } + else + { + if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) + { + projectile.velocity.X = -0.15f; + projectile.velocity.Y = -0.05f; + } + projectile.velocity *= 1.01f; + } + projectile.friendly = false; + projectile.rotation = projectile.velocity.X * 0.05f; + if (Math.Abs(projectile.velocity.X) <= 0f) + return; + projectile.spriteDirection = -projectile.direction; + } + else + { + if (projectile.ai[1] == -1f) + projectile.ai[1] = 17f; + if (projectile.ai[1] > 0f) + { + projectile.ai[1] -= 1f; + } + if (projectile.ai[1] == 0f) + { + projectile.friendly = true; + float minionSpeed = amalgam ? 20f : 8f; + float turnSpeed = 14f; + Vector2 projPos = new Vector2(projectile.Center.X, projectile.Center.Y); + float xDist = center.X - projPos.X; + float yDist = center.Y - projPos.Y - 60f; + Vector2 targetVector = new Vector2(xDist, yDist); + float targetDist = targetVector.Length(); + if (targetDist < 100f) + minionSpeed = amalgam ? 25f : 10f; + + Vector2 homeInVector = projectile.DirectionTo(targetVector); + if (homeInVector.HasNaNs()) + homeInVector = Vector2.UnitY; + + projectile.velocity = (projectile.velocity * turnSpeed + homeInVector * minionSpeed) / (turnSpeed + 1f); + } + else + { + projectile.friendly = false; + if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < 10f) + projectile.velocity *= 1.05f; + } + projectile.rotation = projectile.velocity.X * 0.05f; + if (Math.Abs(projectile.velocity.X) <= 0.2f) + return; + projectile.spriteDirection = -projectile.direction; + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { @@ -90,8 +266,8 @@ namespace CalamityMod.Projectiles.Summon { return; } - float num = (float)damage * 0.25f; - if ((int)num == 0) + float healAmt = damage * 0.25f; + if ((int)healAmt == 0) { return; } @@ -99,9 +275,7 @@ namespace CalamityMod.Projectiles.Summon { return; } - Main.player[Main.myPlayer].lifeSteal -= num; - int num2 = projectile.owner; - Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, projectile.owner, (float)num2, num); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 1f); } } } diff --git a/Projectiles/Summon/RadiantResolutionAura.cs b/Projectiles/Summon/RadiantResolutionAura.cs index 986feb0960..cd6bd7719b 100644 --- a/Projectiles/Summon/RadiantResolutionAura.cs +++ b/Projectiles/Summon/RadiantResolutionAura.cs @@ -91,18 +91,18 @@ namespace CalamityMod.Projectiles.Summon { float angle = MathHelper.Lerp(-MathHelper.ToRadians(30f), MathHelper.ToRadians(30f), i / 3f); Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center).RotatedBy(angle) * 15f, - ModContent.ProjectileType(), radiantOrbDamage / 2, 1f, projectile.owner); + ModContent.ProjectileType(), radiantOrbDamage / 2, projectile.knockBack, projectile.owner); } } if (projectile.ai[1] % radiantOrbAppearRate == radiantOrbAppearRate - 1) { Projectile.NewProjectile(projectile.Center + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(100f, 360f), - projectile.DirectionTo(potentialTarget.Center) * 2f, ModContent.ProjectileType(), radiantOrbDamage, 4f, projectile.owner); + projectile.DirectionTo(potentialTarget.Center) * 2f, ModContent.ProjectileType(), radiantOrbDamage, projectile.knockBack * 4f, projectile.owner); for (int i = 0; i < 4; i++) { float angle = MathHelper.Lerp(-MathHelper.ToRadians(40f), MathHelper.ToRadians(40f), i / 4f); Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center).RotatedBy(angle) * 19f, - ModContent.ProjectileType(), radiantOrbDamage / 2, 1f, projectile.owner); + ModContent.ProjectileType(), radiantOrbDamage / 2, projectile.knockBack, projectile.owner); } } } diff --git a/Projectiles/Summon/SandnadoMinion.cs b/Projectiles/Summon/SandnadoMinion.cs index 58d930428c..edfc16bd79 100644 --- a/Projectiles/Summon/SandnadoMinion.cs +++ b/Projectiles/Summon/SandnadoMinion.cs @@ -103,7 +103,7 @@ namespace CalamityMod.Projectiles.Summon } } Vector2 vector = projectile.position; - float num10 = 600f; + float num10 = 900f; bool flag = false; if (Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) { diff --git a/Projectiles/Summon/SolarGod.cs b/Projectiles/Summon/SolarGod.cs index e57f8abe75..242828bf03 100644 --- a/Projectiles/Summon/SolarGod.cs +++ b/Projectiles/Summon/SolarGod.cs @@ -147,14 +147,8 @@ namespace CalamityMod.Projectiles.Summon } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(200, 200, 200, 200); - } + public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 200); - public override bool CanDamage() - { - return false; - } + public override bool CanDamage() => false; } } diff --git a/Projectiles/Summon/Spikecrag.cs b/Projectiles/Summon/Spikecrag.cs index 0c1125258e..b8118d738a 100644 --- a/Projectiles/Summon/Spikecrag.cs +++ b/Projectiles/Summon/Spikecrag.cs @@ -24,8 +24,6 @@ namespace CalamityMod.Projectiles.Summon projectile.sentry = true; projectile.timeLeft = Projectile.SentryLifeTime; projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 15; } public override void AI() @@ -62,24 +60,21 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity.Y = 10f; } - float centerX = projectile.Center.X; - float centerY = projectile.Center.Y; - float num474 = 1000f; - bool homeIn = false; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].CanBeChasedBy(projectile, false)) - { - float num476 = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); - float num477 = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - homeIn = true; - } - } - } + float maxDistance = 1000f; + bool homeIn = false; + + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[i].width / 2) + (Main.npc[i].height / 2); + + if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance)) + { + homeIn = true; + } + } + } if (projectile.owner == Main.myPlayer && homeIn) { if (projectile.ai[0] != 0f) @@ -90,29 +85,19 @@ namespace CalamityMod.Projectiles.Summon projectile.ai[1] += 1f; if ((projectile.ai[1] % 10f) == 0f) { - int amount = Main.rand.Next(6, 10); + int amount = Main.rand.Next(5, 8); for (int i = 0; i < amount; i++) { float velocityX = Main.rand.NextFloat(-10f, 10f); float velocityY = Main.rand.NextFloat(-15f, -8f); - Projectile.NewProjectile(projectile.oldPosition.X + (float)(projectile.width / 2), projectile.oldPosition.Y + (float)(projectile.height / 2), velocityX, velocityY, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.80), 0f, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.oldPosition.X + (float)(projectile.width / 2), projectile.oldPosition.Y + (float)(projectile.height / 2), velocityX, velocityY, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); } } } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override bool CanDamage() - { - return false; - } + public override bool CanDamage() => false; } } diff --git a/Projectiles/Summon/StormjawBaby.cs b/Projectiles/Summon/StormjawBaby.cs index 3946a48728..fcaad65b60 100644 --- a/Projectiles/Summon/StormjawBaby.cs +++ b/Projectiles/Summon/StormjawBaby.cs @@ -82,8 +82,8 @@ namespace CalamityMod.Projectiles.Summon } } Vector2 vector2_1 = player.Center; - vector2_1.X = vector2_1.X - (float) ((15 + player.width / 2) * player.direction); - vector2_1.X = vector2_1.X - (float) (projectile.minionPos * 40 * player.direction); + vector2_1.X = vector2_1.X - (float)((15 + player.width / 2) * player.direction); + vector2_1.X = vector2_1.X - (float)(projectile.minionPos * 40 * player.direction); int index1 = -1; float num4 = 800f; int num5 = 15; @@ -217,10 +217,10 @@ namespace CalamityMod.Projectiles.Summon } } if (projectile.velocity.X > 0.5f) - projectile.spriteDirection = -1; - else if (projectile.velocity.X < -0.5f) projectile.spriteDirection = 1; - projectile.rotation = projectile.spriteDirection != 1 ? (float) Math.Atan2((double) projectile.velocity.Y, (double) projectile.velocity.X) + 3.14f : (float) Math.Atan2((double) projectile.velocity.Y, (double) projectile.velocity.X); + else if (projectile.velocity.X < -0.5f) + projectile.spriteDirection = -1; + projectile.rotation = projectile.spriteDirection != 1 ? (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.Pi : (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); } if (projectile.ai[0] == 2f) //attack target { @@ -233,9 +233,9 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; projectile.frameCounter = 0; } - else if ((double) Math.Abs(projectile.velocity.X) >= 0.5) + else if (Math.Abs(projectile.velocity.X) >= 0.5f) { - projectile.frameCounter += (int) Math.Abs(projectile.velocity.X); + projectile.frameCounter += (int)Math.Abs(projectile.velocity.X); projectile.frameCounter += 1; if (projectile.frameCounter > 10) { @@ -251,13 +251,13 @@ namespace CalamityMod.Projectiles.Summon projectile.frameCounter = 0; } } - else if ((double) projectile.velocity.Y != 0.0) + else if (projectile.velocity.Y != 0f) { projectile.frameCounter = 0; projectile.frame = 0; } projectile.velocity.Y += 0.4f; - if ((double) projectile.velocity.Y > 10.0) + if (projectile.velocity.Y > 10f) projectile.velocity.Y = 10f; sparkCounter += Main.rand.Next(1,4); @@ -272,7 +272,6 @@ namespace CalamityMod.Projectiles.Summon Main.projectile[spark].Calamity().forceMinion = true; Main.projectile[spark].timeLeft = 120; Main.projectile[spark].penetrate = 3; - ProjectileID.Sets.MinionShot[Main.projectile[spark].type] = true; Main.projectile[spark].usesIDStaticNPCImmunity = true; Main.projectile[spark].idStaticNPCHitCooldown = 10; Main.projectile[spark].usesLocalNPCImmunity = false; @@ -294,27 +293,27 @@ namespace CalamityMod.Projectiles.Summon { float num1 = 700f; float num2 = 20f; - if ((double) projectile.position.Y > Main.worldSurface * 16.0) + if ((double)projectile.position.Y > Main.worldSurface * 16.0) num1 *= 0.7f; NPC npc = Main.npc[index1]; Vector2 center = npc.Center; float num3 = (center - projectile.Center).Length(); Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height); - if ((double) num3 < (double) num1) + if (num3 < num1) { vector2_1 = center; - if ((double) center.Y < (double) projectile.Center.Y - 30.0 && (double) projectile.velocity.Y == 0.0) + if (center.Y < projectile.Center.Y - 30f && projectile.velocity.Y == 0f) { float num6 = Math.Abs(center.Y - projectile.Center.Y); - if ((double) num6 < 120.0) + if (num6 < 120f) projectile.velocity.Y = -10f; - else if ((double) num6 < 210.0) + else if (num6 < 210f) projectile.velocity.Y = -13f; - else if ((double) num6 < 270.0) + else if (num6 < 270f) projectile.velocity.Y = -15f; - else if ((double) num6 < 310.0) + else if (num6 < 310f) projectile.velocity.Y = -17f; - else if ((double) num6 < 380.0) + else if ( num6 < 380f) projectile.velocity.Y = -18f; } } @@ -363,10 +362,10 @@ namespace CalamityMod.Projectiles.Summon float num8 = vector2_1.X - projectile.Center.X; if ((double) Math.Abs(num8) > 5.0) { - if ((double) num8 < 0.0) + if (num8 < 0f) { num7 = -1; - if ((double) projectile.velocity.X > -(double) num2) + if (projectile.velocity.X > -num2) { projectile.velocity.X -= num1; } @@ -378,7 +377,7 @@ namespace CalamityMod.Projectiles.Summon else { num7 = 1; - if ((double) projectile.velocity.X < (double) num2) + if (projectile.velocity.X < num2) { projectile.velocity.X += num1; } @@ -391,13 +390,13 @@ namespace CalamityMod.Projectiles.Summon else { projectile.velocity.X *= 0.9f; - if ((double) Math.Abs(projectile.velocity.X) < (double) num1 * 2.0) + if (Math.Abs(projectile.velocity.X) < num1 * 2f) projectile.velocity.X = 0.0f; } if (num7 != 0) { - int num9 = (int) ((double) projectile.position.X + (double) (projectile.width / 2)) / 16; - int num10 = (int) projectile.position.Y / 16; + int num9 = (int)projectile.Center.X / 16; + int num10 = (int)projectile.position.Y / 16; int i = num9 + num7 + (int) projectile.velocity.X; for (int j = num10; j < num10 + projectile.height / 16 + 1; ++j) { @@ -441,17 +440,17 @@ namespace CalamityMod.Projectiles.Summon } } } - if ((double) projectile.velocity.X > (double) num3) + if (projectile.velocity.X > num3) projectile.velocity.X = num3; - if ((double) projectile.velocity.X < -(double) num3) + if (projectile.velocity.X < -num3) projectile.velocity.X = -num3; - if ((double) projectile.velocity.X < 0.0) + if (projectile.velocity.X < 0f) projectile.direction = -1; - if ((double) projectile.velocity.X > 0.0) + if (projectile.velocity.X > 0f) projectile.direction = 1; - if ((double) projectile.velocity.X > (double) num1 && num7 == 1) + if (projectile.velocity.X > num1 && num7 == 1) projectile.direction = 1; - if ((double) projectile.velocity.X < -(double) num1 && num7 == -1) + if (projectile.velocity.X < -num1 && num7 == -1) projectile.direction = -1; projectile.spriteDirection = -projectile.direction; projectile.rotation = 0f; @@ -467,7 +466,7 @@ namespace CalamityMod.Projectiles.Summon if (xDist > 0) projectile.spriteDirection = projectile.direction; } - else if ((double) Math.Abs(projectile.velocity.X) >= 0.5) + else if (Math.Abs(projectile.velocity.X) >= 0.5f) { projectile.frameCounter += (int) Math.Abs(projectile.velocity.X); projectile.frameCounter += 1; @@ -485,18 +484,18 @@ namespace CalamityMod.Projectiles.Summon projectile.frameCounter = 0; } } - else if ((double) projectile.velocity.Y != 0.0) + else if (projectile.velocity.Y != 0f) { projectile.frameCounter = 0; projectile.frame = 0; } projectile.velocity.Y += 0.4f; - if ((double) projectile.velocity.Y > 10.0) + if (projectile.velocity.Y > 10f) projectile.velocity.Y = 10f; } if (projectile.ai[0] != 2f) { - Rectangle rectangle = new Rectangle((int)((double)projectile.position.X + (double)projectile.velocity.X * 0.5 - 4.0), (int)((double)projectile.position.Y + (double)projectile.velocity.Y * 0.5 - 4.0), projectile.width + 8, projectile.height + 8); + Rectangle rectangle = new Rectangle((int)(projectile.position.X + projectile.velocity.X * 0.5f - 4f), (int)(projectile.position.Y + projectile.velocity.Y * 0.5f - 4f), projectile.width + 8, projectile.height + 8); for (int i = 0; i < Main.maxNPCs; i++) { if (Main.npc[i].active && !Main.npc[i].dontTakeDamage && !Main.npc[i].friendly && !Main.npc[i].townNPC && Main.npc[i].immune[projectile.owner] <= 0) @@ -517,7 +516,6 @@ namespace CalamityMod.Projectiles.Summon Main.projectile[spark].Calamity().forceMinion = true; Main.projectile[spark].timeLeft = 120; Main.projectile[spark].penetrate = 3; - ProjectileID.Sets.MinionShot[Main.projectile[spark].type] = true; Main.projectile[spark].usesIDStaticNPCImmunity = true; Main.projectile[spark].idStaticNPCHitCooldown = 10; Main.projectile[spark].usesLocalNPCImmunity = false; @@ -537,10 +535,7 @@ namespace CalamityMod.Projectiles.Summon return true; } - public override bool OnTileCollide(Vector2 oldVelocity) - { - return false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; public override void Kill(int timeLeft) { diff --git a/Projectiles/Summon/TacticalPlagueEngineSummon.cs b/Projectiles/Summon/TacticalPlagueEngineSummon.cs index 62822d0f47..6c9cefda9f 100644 --- a/Projectiles/Summon/TacticalPlagueEngineSummon.cs +++ b/Projectiles/Summon/TacticalPlagueEngineSummon.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Projectiles.Summon public static Item FalseGun = null; public override void SetStaticDefaults() { - DisplayName.SetDefault("Tactical Plague Engine"); + DisplayName.SetDefault("Tactical Plague Jet"); Main.projFrames[projectile.type] = 3; ProjectileID.Sets.MinionSacrificable[projectile.type] = true; ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; @@ -128,6 +128,12 @@ namespace CalamityMod.Projectiles.Summon projectile.spriteDirection = -1; } projectile.rotation = projectile.rotation.AngleTowards(0f, 0.2f); + + if (distanceVector.Length() > 2700f) + { + projectile.Center = player.Center; + projectile.netUpdate = true; + } } else { diff --git a/Projectiles/Summon/TundraFlameBlossom.cs b/Projectiles/Summon/TundraFlameBlossom.cs index 72c66de54c..3833bfeb96 100644 --- a/Projectiles/Summon/TundraFlameBlossom.cs +++ b/Projectiles/Summon/TundraFlameBlossom.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - projectile.Center = Main.player[projectile.owner].Center + (projectile.ai[1] / 32f).ToRotationVector2() * 95f; + projectile.Center = player.Center + (projectile.ai[1] / 32f).ToRotationVector2() * 95f; projectile.scale = 1f + (float)Math.Sin(projectile.ai[1] / 40f) * 0.085f; projectile.Opacity = 1f - (float)Math.Sin(projectile.ai[1] / 45f) * 0.1f - 0.1f; // Range of 1f to 0.8f projectile.rotation += MathHelper.ToRadians(5f); diff --git a/Projectiles/Summon/VileFeederProjectile.cs b/Projectiles/Summon/VileFeederProjectile.cs index fd7222d7a2..ab7a7be023 100644 --- a/Projectiles/Summon/VileFeederProjectile.cs +++ b/Projectiles/Summon/VileFeederProjectile.cs @@ -72,7 +72,6 @@ namespace CalamityMod.Projectiles.Summon projectile.ai[0] += 1f; if (projectile.ai[0] > 30f) { - projectile.ai[0] = 30f; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; @@ -168,6 +167,7 @@ namespace CalamityMod.Projectiles.Summon } else { + projectile.ai[0] += 15f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Typeless/ArtifactOfResilienceShards.cs b/Projectiles/Typeless/ArtifactOfResilienceShards.cs index c638022950..edd9c4e2c1 100644 --- a/Projectiles/Typeless/ArtifactOfResilienceShards.cs +++ b/Projectiles/Typeless/ArtifactOfResilienceShards.cs @@ -1,4 +1,5 @@ -using CalamityMod.Dusts; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Dusts; using CalamityMod.Projectiles.Damageable; using Microsoft.Xna.Framework; using Terraria; @@ -69,6 +70,23 @@ namespace CalamityMod.Projectiles.Typeless projectile.velocity = Utils.NextVector2Circular(Main.rand, 18f, 9f); projectile.localAI[1] = 1; } + if (projectile.modProjectile is ArtifactOfResilienceShard1) + { + for (int i = 0; i < Main.npc.Length; i++) + { + if (Main.npc[i].active && + Main.npc[i].Distance(StartingPosition) < projectile.ai[1] && + Main.npc[i].damage > 0) + { + if (Main.npc[i].Calamity().relicOfResilienceCooldown <= 0) + { + Main.npc[i].Calamity().relicOfResilienceCooldown = 600; + Main.npc[i].Calamity().relicOfResilienceWeakness = 180; + Main.npc[i].AddBuff(ModContent.BuffType(), Main.npc[i].Calamity().relicOfResilienceWeakness); + } + } + } + } } // Falling else diff --git a/Projectiles/Typeless/EnergyShell.cs b/Projectiles/Typeless/EnergyShell.cs new file mode 100644 index 0000000000..8fbc89e969 --- /dev/null +++ b/Projectiles/Typeless/EnergyShell.cs @@ -0,0 +1,72 @@ +using CalamityMod.Buffs.Cooldowns; +using CalamityMod.Items.Weapons.Melee; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class EnergyShell : ModProjectile + { + private bool playedSound = false; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Energy Shell"); + Main.projFrames[projectile.type] = 6; + } + + public override void SetDefaults() + { + projectile.width = 58; + projectile.height = 72; + projectile.ignoreWater = true; + projectile.timeLeft = 300; + projectile.tileCollide = false; + projectile.friendly = true; + projectile.penetrate = -1; + } + + public override void AI() + { + if (!playedSound) + { + Main.PlaySound(SoundID.Item92, (int)projectile.position.X, (int)projectile.position.Y); + playedSound = true; + } + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= 6) + { + projectile.frame = 0; + } + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.15f / 255f, (255 - projectile.alpha) * 0.15f / 255f, (255 - projectile.alpha) * 0.01f / 255f); + if (projectile.timeLeft < 51) //fade out + { + projectile.alpha += 5; + } + Player player = Main.player[projectile.owner]; + projectile.Center = player.Center; + //if player is dead, null, or stops holding the Lion Heart, kill the projectile + if (player.dead || player is null || player.ActiveItem().type != ModContent.ItemType()) + { + projectile.Kill(); + } + } + + public override void Kill(int timeLeft) + { + Player player = Main.player[projectile.owner]; + Main.PlaySound(SoundID.Item94, (int)projectile.position.X, (int)projectile.position.Y); + player.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(45f)); + } + + public override bool CanDamage() => false; + } +} diff --git a/Projectiles/Typeless/EnergyShell.png b/Projectiles/Typeless/EnergyShell.png new file mode 100644 index 0000000000..5ed22b9704 Binary files /dev/null and b/Projectiles/Typeless/EnergyShell.png differ diff --git a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs index 327311bba7..6044b01d8e 100644 --- a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs +++ b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs @@ -1,5 +1,6 @@ using CalamityMod.CalPlayer; using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -77,6 +78,17 @@ namespace CalamityMod.Projectiles.Typeless projectile.ai[0]++; if (projectile.velocity == Vector2.Zero) { + // Immediately die if the player is not holding the spear + if (player.ActiveItem() == null) + { + projectile.Kill(); + return; + } + if (player.ActiveItem().type != ModContent.ItemType()) + { + projectile.Kill(); + return; + } projectile.rotation = projectile.AngleTo(Main.MouseWorld); projectile.Center = player.Center; if (projectile.ai[0] >= WaitTimeRequiredForCharge) diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index 2e164cbcd1..507235a53a 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -10,6 +10,8 @@ using CalamityMod.Tiles.SunkenSea; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; +using System.Reflection; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,6 +20,7 @@ namespace CalamityMod.Tiles { public class CalamityGlobalTile : GlobalTile { + public static IList WaterStyles => (IList)typeof(WaterStyleLoader).GetField("waterStyles", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); public static ushort[] PlantTypes = new ushort[] { TileID.Plants, @@ -33,12 +36,12 @@ namespace CalamityMod.Tiles (ushort)ModContent.TileType(), }; - public override bool PreHitWire(int i, int j, int type) - { - return !CalamityWorld.bossRushActive; - } + public override bool PreHitWire(int i, int j, int type) + { + return !CalamityWorld.bossRushActive; + } - public override bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak) + public override bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak) { // Custom plant framing for (int k = 0; k < PlantTypes.Length; k++) diff --git a/Tiles/Furniture/Fountains/AbyssFountainTile.cs b/Tiles/Furniture/Fountains/AbyssFountainTile.cs new file mode 100644 index 0000000000..b2349ad313 --- /dev/null +++ b/Tiles/Furniture/Fountains/AbyssFountainTile.cs @@ -0,0 +1,82 @@ +using Microsoft.Xna.Framework; +using System.Linq; +using Terraria; +using Terraria.ModLoader; +using CalamityMod.Items.Placeables.Furniture.Fountains; + +namespace CalamityMod.Tiles.Furniture.Fountains +{ + public class AbyssFountainTile : ModTile + { + public override void SetDefaults() + { + this.SetUpFountain(); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Abyss Water Fountain"); + AddMapEntry(new Color(71, 93, 107), name); + animationFrameHeight = 72; + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (Main.tile[i, j].frameX < 36) + { + if (CalamityGlobalTile.WaterStyles.Any((style) => style.Name == "AbyssWater")) + { + Main.fountainColor = CalamityGlobalTile.WaterStyles.FirstOrDefault((style) => style.Name == "AbyssWater").Type; + } + } + } + + public override bool HasSmartInteract() + { + return true; + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 1, 0f, 0f, 1, new Color(119, 102, 255), 1f); + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 33, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void AnimateTile(ref int frame, ref int frameCounter) + { + frameCounter++; + if (frameCounter >= 6) + { + frame = (frame + 1) % 4; + frameCounter = 0; + } + } + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(i * 16, j * 16, 16, 32, ModContent.ItemType()); + } + + public override void HitWire(int i, int j) + { + CalamityUtils.LightHitWire(Type, i, j, 2, 4); + } + + public override bool NewRightClick(int i, int j) + { + CalamityUtils.LightHitWire(Type, i, j, 2, 4); + return true; + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.showItemIcon = true; + player.showItemIcon2 = ModContent.ItemType(); + } + } +} \ No newline at end of file diff --git a/Tiles/Furniture/Fountains/AbyssFountainTile.png b/Tiles/Furniture/Fountains/AbyssFountainTile.png new file mode 100644 index 0000000000..68927bab25 Binary files /dev/null and b/Tiles/Furniture/Fountains/AbyssFountainTile.png differ diff --git a/Tiles/Furniture/Fountains/AbyssFountainTile_Highlight.png b/Tiles/Furniture/Fountains/AbyssFountainTile_Highlight.png new file mode 100644 index 0000000000..1d1e01fe1a Binary files /dev/null and b/Tiles/Furniture/Fountains/AbyssFountainTile_Highlight.png differ diff --git a/Tiles/Furniture/Fountains/AstralFountainTile.cs b/Tiles/Furniture/Fountains/AstralFountainTile.cs new file mode 100644 index 0000000000..a3745c8a22 --- /dev/null +++ b/Tiles/Furniture/Fountains/AstralFountainTile.cs @@ -0,0 +1,83 @@ +using Microsoft.Xna.Framework; +using System.Linq; +using Terraria; +using Terraria.ModLoader; +using CalamityMod.Dusts; +using CalamityMod.Items.Placeables.Furniture.Fountains; + +namespace CalamityMod.Tiles.Furniture.Fountains +{ + public class AstralFountainTile : ModTile + { + public override void SetDefaults() + { + this.SetUpFountain(); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Astral Water Fountain"); + AddMapEntry(new Color(59, 50, 77), name); + animationFrameHeight = 72; + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (Main.tile[i, j].frameX < 36) + { + if (CalamityGlobalTile.WaterStyles.Any((style) => style.Name == "AstralWater")) + { + Main.fountainColor = CalamityGlobalTile.WaterStyles.FirstOrDefault((style) => style.Name == "AstralWater").Type; + } + } + } + + public override bool HasSmartInteract() + { + return true; + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, ModContent.DustType()); + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, ModContent.DustType()); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void AnimateTile(ref int frame, ref int frameCounter) + { + frameCounter++; + if (frameCounter >= 6) + { + frame = (frame + 1) % 4; + frameCounter = 0; + } + } + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(i * 16, j * 16, 16, 32, ModContent.ItemType()); + } + + public override void HitWire(int i, int j) + { + CalamityUtils.LightHitWire(Type, i, j, 2, 4); + } + + public override bool NewRightClick(int i, int j) + { + CalamityUtils.LightHitWire(Type, i, j, 2, 4); + return true; + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.showItemIcon = true; + player.showItemIcon2 = ModContent.ItemType(); + } + } +} \ No newline at end of file diff --git a/Tiles/Furniture/Fountains/AstralFountainTile.png b/Tiles/Furniture/Fountains/AstralFountainTile.png new file mode 100644 index 0000000000..126498ac4d Binary files /dev/null and b/Tiles/Furniture/Fountains/AstralFountainTile.png differ diff --git a/Tiles/Furniture/Fountains/AstralFountainTile_Highlight.png b/Tiles/Furniture/Fountains/AstralFountainTile_Highlight.png new file mode 100644 index 0000000000..169f6ac0a3 Binary files /dev/null and b/Tiles/Furniture/Fountains/AstralFountainTile_Highlight.png differ diff --git a/Tiles/Furniture/Fountains/SulphurousFountainTile.cs b/Tiles/Furniture/Fountains/SulphurousFountainTile.cs new file mode 100644 index 0000000000..ad393f4ca1 --- /dev/null +++ b/Tiles/Furniture/Fountains/SulphurousFountainTile.cs @@ -0,0 +1,82 @@ +using Microsoft.Xna.Framework; +using System.Linq; +using Terraria; +using Terraria.ModLoader; +using CalamityMod.Items.Placeables.Furniture.Fountains; + +namespace CalamityMod.Tiles.Furniture.Fountains +{ + public class SulphurousFountainTile : ModTile + { + public override void SetDefaults() + { + this.SetUpFountain(); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Sulphuric Water Fountain"); + AddMapEntry(new Color(104, 195, 255), name); + animationFrameHeight = 72; + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (Main.tile[i, j].frameX < 36) + { + if (CalamityGlobalTile.WaterStyles.Any((style) => style.Name == "SulphuricWater")) + { + Main.fountainColor = CalamityGlobalTile.WaterStyles.FirstOrDefault((style) => style.Name == "SulphuricWater").Type; + } + } + } + + public override bool HasSmartInteract() + { + return true; + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 1, 0f, 0f, 1, new Color(119, 102, 255), 1f); + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 33, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void AnimateTile(ref int frame, ref int frameCounter) + { + frameCounter++; + if (frameCounter >= 6) + { + frame = (frame + 1) % 4; + frameCounter = 0; + } + } + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(i * 16, j * 16, 16, 32, ModContent.ItemType()); + } + + public override void HitWire(int i, int j) + { + CalamityUtils.LightHitWire(Type, i, j, 2, 4); + } + + public override bool NewRightClick(int i, int j) + { + CalamityUtils.LightHitWire(Type, i, j, 2, 4); + return true; + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.showItemIcon = true; + player.showItemIcon2 = ModContent.ItemType(); + } + } +} \ No newline at end of file diff --git a/Tiles/Furniture/Fountains/SulphurousFountainTile.png b/Tiles/Furniture/Fountains/SulphurousFountainTile.png new file mode 100644 index 0000000000..9dfcecd6e6 Binary files /dev/null and b/Tiles/Furniture/Fountains/SulphurousFountainTile.png differ diff --git a/Tiles/Furniture/Fountains/SulphurousFountainTile_Highlight.png b/Tiles/Furniture/Fountains/SulphurousFountainTile_Highlight.png new file mode 100644 index 0000000000..31243c312d Binary files /dev/null and b/Tiles/Furniture/Fountains/SulphurousFountainTile_Highlight.png differ diff --git a/Tiles/Furniture/Fountains/SunkenSeaFountainTile.cs b/Tiles/Furniture/Fountains/SunkenSeaFountainTile.cs new file mode 100644 index 0000000000..0f10a9c4db --- /dev/null +++ b/Tiles/Furniture/Fountains/SunkenSeaFountainTile.cs @@ -0,0 +1,82 @@ +using Microsoft.Xna.Framework; +using System.Linq; +using Terraria; +using Terraria.ModLoader; +using CalamityMod.Items.Placeables.Furniture.Fountains; + +namespace CalamityMod.Tiles.Furniture.Fountains +{ + public class SunkenSeaFountainTile : ModTile + { + public override void SetDefaults() + { + this.SetUpFountain(); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Sunken Water Fountain"); + AddMapEntry(new Color(104, 195, 255), name); + animationFrameHeight = 72; + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (Main.tile[i, j].frameX < 36) + { + if (CalamityGlobalTile.WaterStyles.Any((style) => style.Name == "SunkenSeaWater")) + { + Main.fountainColor = CalamityGlobalTile.WaterStyles.FirstOrDefault((style) => style.Name == "SunkenSeaWater").Type; + } + } + } + + public override bool HasSmartInteract() + { + return true; + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 1, 0f, 0f, 1, new Color(119, 102, 255), 1f); + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 33, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void AnimateTile(ref int frame, ref int frameCounter) + { + frameCounter++; + if (frameCounter >= 6) + { + frame = (frame + 1) % 4; + frameCounter = 0; + } + } + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(i * 16, j * 16, 16, 32, ModContent.ItemType()); + } + + public override void HitWire(int i, int j) + { + CalamityUtils.LightHitWire(Type, i, j, 2, 4); + } + + public override bool NewRightClick(int i, int j) + { + CalamityUtils.LightHitWire(Type, i, j, 2, 4); + return true; + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.showItemIcon = true; + player.showItemIcon2 = ModContent.ItemType(); + } + } +} \ No newline at end of file diff --git a/Tiles/Furniture/Fountains/SunkenSeaFountainTile.png b/Tiles/Furniture/Fountains/SunkenSeaFountainTile.png new file mode 100644 index 0000000000..e8ceb8d0a1 Binary files /dev/null and b/Tiles/Furniture/Fountains/SunkenSeaFountainTile.png differ diff --git a/Tiles/Furniture/Fountains/SunkenSeaFountainTile_Highlight.png b/Tiles/Furniture/Fountains/SunkenSeaFountainTile_Highlight.png new file mode 100644 index 0000000000..5866fcb8b8 Binary files /dev/null and b/Tiles/Furniture/Fountains/SunkenSeaFountainTile_Highlight.png differ diff --git a/UI/RipperUI.cs b/UI/RipperUI.cs index 95a6f46f9f..d8ead9eb62 100644 --- a/UI/RipperUI.cs +++ b/UI/RipperUI.cs @@ -5,6 +5,7 @@ using Terraria; using Terraria.ModLoader; using CalamityMod.World; using Microsoft.Xna.Framework.Input; +using System.Collections.Generic; namespace CalamityMod.UI { @@ -257,10 +258,14 @@ namespace CalamityMod.UI private static void CheckGarbageCornerPos() { - if (rageDrawPos.X <= 60f && rageDrawPos.Y <= 20f) + // This should only happen if something happens to the config file. + if (rageDrawPos == Vector2.Zero) rageDrawPos = new Vector2(DefaultRagePosX, DefaultRagePosY); - if (adrenDrawPos.X <= 60f && adrenDrawPos.Y <= 20f) + rageDrawPos = Vector2.Clamp(rageDrawPos, Vector2.Zero, new Vector2(Main.screenWidth - 104f, Main.screenHeight - 24f)); + + if (adrenDrawPos == Vector2.Zero) adrenDrawPos = new Vector2(DefaultAdrenPosX, DefaultAdrenPosY); + adrenDrawPos = Vector2.Clamp(adrenDrawPos, Vector2.Zero, new Vector2(Main.screenWidth - 104f, Main.screenHeight - 24f)); } private static Vector2 GetShakeOffset() diff --git a/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index 70f7fe3459..cf4cc53275 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -53,6 +53,7 @@ namespace CalamityMod public static CalamityGlobalNPC Calamity(this NPC npc) => npc.GetGlobalNPC(); public static CalamityGlobalItem Calamity(this Item item) => item.GetGlobalItem(); public static CalamityGlobalProjectile Calamity(this Projectile proj) => proj.GetGlobalProjectile(); + public static Item ActiveItem(this Player player) => Main.mouseItem.IsAir ? player.HeldItem : Main.mouseItem; #endregion #region Player Utilities @@ -302,7 +303,7 @@ namespace CalamityMod public static Rectangle FixSwingHitbox(float hitboxWidth, float hitboxHeight) { Player player = Main.player[Main.myPlayer]; - Item item = player.inventory[player.selectedItem]; + Item item = player.ActiveItem(); float hitbox_X, hitbox_Y; float mountOffsetY = player.mount.PlayerOffsetHitbox; @@ -642,6 +643,16 @@ namespace CalamityMod } } } + + public static int DamageSoftCap(double dmgInput, int cap) + { + int newDamage = (int)(dmgInput); + if (newDamage > cap) + { + newDamage = (int)((dmgInput - cap) * 0.1) + cap; + } + return newDamage; + } #endregion #region Tile Utilities @@ -2138,6 +2149,33 @@ namespace CalamityMod // All work benches count as tables. mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); } + + /// + /// Extension which initializes a ModTile to be a fountain. + /// + /// The ModTile which is being initialized. + internal static void SetUpFountain(this ModTile mt) + { + //All fountains are immune to lava + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = false; + Main.tileWaterDeath[mt.Type] = false; + //TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); + //TileObjectData.newTile.Width = 2; + TileObjectData.newTile.LavaDeath = false; + TileObjectData.addTile(mt.Type); + TileID.Sets.HasOutlines[mt.Type] = true; + + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 4; + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.Origin = new Point16(0, 3); + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 2, 0); + TileObjectData.addTile(mt.Type); + } #endregion #endregion @@ -2155,12 +2193,12 @@ namespace CalamityMod public static void DrawFishingLine(this Projectile projectile, int fishingRodType, Color poleColor, int xPositionAdditive = 45, float yPositionAdditive = 35f) { Player player = Main.player[projectile.owner]; - if (projectile.bobber && player.inventory[player.selectedItem].holdStyle > 0) + if (projectile.bobber && player.ActiveItem().holdStyle > 0) { float pPosX = player.MountedCenter.X; float pPosY = player.MountedCenter.Y; pPosY += player.gfxOffY; - int type = player.inventory[player.selectedItem].type; + int type = player.ActiveItem().type; float gravDir = player.gravDir; if (type == fishingRodType) diff --git a/Utilities/DropHelper.cs b/Utilities/DropHelper.cs index 2a80c9ee6c..25a57252cc 100644 --- a/Utilities/DropHelper.cs +++ b/Utilities/DropHelper.cs @@ -231,6 +231,44 @@ namespace CalamityMod return dropped; } + + /// + /// Drops an item that can be replaced by a given RIV + /// + /// The NPC which should drop the item. + /// The ID of the normal item to drop. + /// The ID of the RIV to drop. + /// The chance that one of the two will drop. A decimal number <= 1.0. + /// The chance that the RIV will drop. A decimal number <= 1.0. + public static void DropItemRIV(NPC npc, int itemID, int rareID, float itemChance, float rareChance) + { + float f = Main.rand.NextFloat(); + bool replaceWithRare = f <= rareChance; // 1/X chance overall of getting RIV + if (f <= itemChance) // 1/X chance of getting original OR the RIV replacing it + { + DropItemCondition(npc, itemID, !replaceWithRare); + DropItemCondition(npc, rareID, replaceWithRare); + } + } + + /// + /// Drops an item that can be replaced by a given RIV + /// + /// The player which should receive the item. + /// The ID of the normal item to drop. + /// The ID of the RIV to drop. + /// The chance that one of the two will drop. A decimal number <= 1.0. + /// The chance that the RIV will drop. A decimal number <= 1.0. + public static void DropItemRIV(Player player, int itemID, int rareID, float itemChance, float rareChance) + { + float f = Main.rand.NextFloat(); + bool replaceWithRare = f <= rareChance; // 1/X chance overall of getting RIV + if (f <= itemChance) // 1/X chance of getting original OR the RIV replacing it + { + DropItemCondition(player, itemID, !replaceWithRare); + DropItemCondition(player, rareID, replaceWithRare); + } + } #endregion #region NPC Item Drops 100% Chance diff --git a/Waters/AbyssWater.cs b/Waters/AbyssWater.cs index acf70e4ef8..76bc725e05 100644 --- a/Waters/AbyssWater.cs +++ b/Waters/AbyssWater.cs @@ -1,3 +1,4 @@ +using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -8,7 +9,8 @@ namespace CalamityMod.Waters { public override bool ChooseWaterStyle() { - return Main.LocalPlayer.Calamity().ZoneAbyss; + CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); + return modPlayer.ZoneAbyss; } public override int ChooseWaterfallStyle() diff --git a/Waters/AstralWater.cs b/Waters/AstralWater.cs index 61c8de3d82..82d110d09d 100644 --- a/Waters/AstralWater.cs +++ b/Waters/AstralWater.cs @@ -1,3 +1,4 @@ +using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -8,7 +9,8 @@ namespace CalamityMod.Waters { public override bool ChooseWaterStyle() { - return Main.LocalPlayer.Calamity().ZoneAstral; + CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); + return modPlayer.ZoneAstral; } public override int ChooseWaterfallStyle() diff --git a/Waters/SulphuricWater.cs b/Waters/SulphuricWater.cs index 1c0a59d613..61d90d8335 100644 --- a/Waters/SulphuricWater.cs +++ b/Waters/SulphuricWater.cs @@ -1,3 +1,4 @@ +using CalamityMod.CalPlayer; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; @@ -32,7 +33,9 @@ namespace CalamityMod.Waters bool inYZone = Main.LocalPlayer.Center.Y < Main.rockLayer * 16f - 320 && Main.LocalPlayer.Center.Y >= 5800f; - return (inXZone && inYZone) || Main.LocalPlayer.Calamity().ZoneSulphur; + CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); + bool greenWater = (inXZone && inYZone) || modPlayer.ZoneSulphur; + return greenWater; } public override int ChooseWaterfallStyle() diff --git a/Waters/SunkenSeaWater.cs b/Waters/SunkenSeaWater.cs index 16f9e35348..e8cb9e7ff5 100644 --- a/Waters/SunkenSeaWater.cs +++ b/Waters/SunkenSeaWater.cs @@ -1,3 +1,4 @@ +using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -8,7 +9,8 @@ namespace CalamityMod.Waters { public override bool ChooseWaterStyle() { - return Main.LocalPlayer.Calamity().ZoneSunkenSea; + CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); + return modPlayer.ZoneSunkenSea; } public override int ChooseWaterfallStyle() diff --git a/World/Abyss.cs b/World/Abyss.cs index d7f899eec2..e63c4a6171 100644 --- a/World/Abyss.cs +++ b/World/Abyss.cs @@ -714,7 +714,7 @@ namespace CalamityMod.World #endregion #region Generating Chests - public const int CheckCutoffDistance = 35; + public const int CheckCutoffDistance = 15; public static void PlaceRustyChests() { // Ambiguity bullshit. @@ -759,40 +759,45 @@ namespace CalamityMod.World #endregion #region Misc Functions - public static List YStartBlacklist = new List() + public static List YStartWhitelist = new List() { - TileID.Cloud, - TileID.RainCloud, - TileID.SnowCloud, - TileID.Sunplate, - TileID.Tables, - TileID.Chairs, - TileID.ClosedDoor, - TileID.OpenDoor, - TileID.Banners, - TileID.Crimtane, - TileID.Demonite, - TileID.Containers + TileID.Sand, + TileID.Ebonsand, + TileID.Crimsand, + TileID.Grass, + TileID.CorruptGrass, + TileID.FleshGrass, + TileID.ClayBlock, + TileID.Mud, + TileID.Copper, + TileID.Tin, + TileID.Iron, + TileID.Lead, + TileID.Silver, + TileID.Tungsten, + TileID.Crimstone, + TileID.Ebonstone, + TileID.JungleGrass // Yes, this can happen on rare occasion }; public static void DetermineYStart() { - int maxHeight = int.MaxValue; - for (int i = 0; i < 15; i++) + int maxHeight = 0; + for (int i = 0; i < BiomeWidth; i++) { int xCheck = CalamityWorld.abyssSide ? BiomeWidth - i : Main.maxTilesX - BiomeWidth + i; - int YStart = 1; - while (!Main.tile[xCheck, YStart].active() || YStartBlacklist.Contains(Main.tile[xCheck, YStart].type)) + int YStart = (int)WorldGen.worldSurfaceLow - 20; // 30 tiles below the absolute lowest a floating island can spawn + while (!Main.tile[xCheck, YStart].active() || !YStartWhitelist.Contains(Main.tile[xCheck, YStart].type) || + Main.tile[xCheck, YStart].type == TileID.LivingWood || Main.tile[xCheck, YStart].type == TileID.LeafBlock) { YStart++; if (YStart > Main.rockLayer - 40) break; } - if (maxHeight > YStart) - maxHeight = YStart; + maxHeight += YStart; } - YStart = maxHeight; + YStart = maxHeight / BiomeWidth; } public static void GrowSaplingImmediately(int i, int j) { diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index 1eed03e300..b2adc93dff 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -968,21 +968,35 @@ namespace CalamityMod.World if (rainingAcid) { - for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) - { - if (Main.player[playerIndex].active) - { - if (Main.player[playerIndex].Calamity().ZoneSulphur) - { - startAcidicDownpour = true; - CalamityMod.UpdateServerBoolean(); - } - } - } + if (!startAcidicDownpour) + { + int sulphSeaWidth = Abyss.BiomeWidth; + for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + { + // A variable named "player" already exists above, which retrieves the player who is closest to the map center. + Player player2 = Main.player[playerIndex]; + if (player2.active) + { + // An artificial biome can be made, and therefore, the event could be started by an artificial biome. + // While fighting the event in an artificial biome is not bad, having it be started by a patch of Sulphurous Sand + // would definitely be strange. + // Because of this, this code is executed based on if the player is in the sea (based on tile count) AND position relative to the naturally generated sea. + if (((player2.Center.X <= (sulphSeaWidth + 60f) * 16f && abyssSide) || + (player2.Center.X >= (Main.maxTilesX - (sulphSeaWidth + 60f)) * 16f && !abyssSide)) && + player2.Calamity().ZoneSulphur) + { + startAcidicDownpour = true; + CalamityMod.UpdateServerBoolean(); + break; + } + } + } + } + // Makes rain pour at its maximum intensity (but only after an idiot meanders into the Sulphurous Sea) // You'll never catch me, Fabs, Not when I shift into MAXIMUM OVERDRIVE!! - if (startAcidicDownpour || forcedDownpourWithTear) - { + if ((startAcidicDownpour || forcedDownpourWithTear) && !NPC.AnyNPCs(ModContent.NPCType())) + { Main.raining = true; Main.cloudBGActive = 1f; Main.numCloudsTemp = Main.cloudLimit; @@ -994,7 +1008,7 @@ namespace CalamityMod.World } // Summon Old Duke tornado post-Polter as needed - if (downedPolterghast && acidRainPoints == 2f) + if (downedPolterghast && acidRainPoints == 2) { if (!NPC.AnyNPCs(ModContent.NPCType()) && CalamityUtils.CountProjectiles(ModContent.ProjectileType()) <= 0) diff --git a/build.txt b/build.txt index ac65ff47ea..b61b3f685b 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = Fabsol and the Dev Team -version = 1.4.4.003 +version = 1.4.4.004 displayName = Calamity Mod (No Calamity Music) homepage = https://forums.terraria.org/index.php?threads/calamity-mod.44065/ buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, .git\*, LICENSE, README.md, .editorconfig, .gitignore, .gitattributes